我想根据 json 整数数组过滤行,例如,我的表如下所示
| Id | Name | TypeJson |
| --- | ---------- | -------- |
| 1 | Name One | [1,2] |
| 2 | Name Two | [2,3] |
| 3 | Name Three | [4,7] |
其中 Id 是 int 类型,Name - 文本,TypeJson - jsonb。
我正在尝试通过以下查询来过滤行
await _dbContect.Table
.Where(x => !string.IsNullOrEmpty(x.TypeJson) &&
EF.Functions.JsonExistAny(x.TypeJson, "2")
.ToListAsync();
我希望得到 1 行和 2 行结果,但出现意外错误
Npgsql.PostgresException (0x80004005): 42883: function btrim(jsonb, unknown) does not exist
...
Exception data:
Severity: ERROR
SqlState: 42883
MessageText: function btrim(jsonb, unknown) does not exist
Hint: No function matches the given name and argument types. You might need to add explicit type casts.
Position: 593
File: parse_func.c
Line: 528
Routine: ParseFuncOrColumn
我应该通过吗"2"
以某种特定的格式或抛出的异常是什么?
将此问题发布在 npgsql github 上,正如预期的那样,这是我这边的问题,因为该列是 jsonb 类型字符串函数,例如IsNullOrEmpty()
and IsNullOrWhiteSpace()
不能应用于它,而且甚至不需要它,因为 EF json 函数无论如何都会将 null 值过滤为 false。
链接到 github 上的问题
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)