dot*_*ive 6 c# postgresql entity-framework-core
我有一个实体,其字段定义为 GUID 数组。我想知道 DB 中是否有一些行包含作为参数传递的值。
根据文档,我可以进行.Where(x => x.ArrayField.Contains(arg))or .Where(x => x.ArrayField.Any(f => f == arg))(也可以将 arg 包装到单元素数组中并执行.Any(f => array.Contains(f)))调用。
但实际上我得到了这个:
System.InvalidOperationException: Error generated for warning 'Microsoft.EntityFrameworkCore.Query.QueryClientEvaluationWarning: The LINQ expression 'where {[x].Ids => Contains(Id_2)}' could not be translated and will be evaluated locally.'. This exception can be suppressed or logged by passing event ID 'RelationalEventId.QueryClientEvaluationWarning' to the 'ConfigureWarnings' method in 'DbContext.OnConfiguring' or 'AddDbContext'.
Run Code Online (Sandbox Code Playgroud)
我的查询如下所示:
var entities = await context.Query<Entity>
.Where(x => x.Ids.Contains(Id))
.ToArrayAsync();
Run Code Online (Sandbox Code Playgroud)
为什么是错误的?或者应该有一些额外的配置?
在 DB 侧列定义为uuid[]. 我不是 Postgre 专家,但假设它对数据库来说已经足够了。
UPD:该字段在 C# 端定义为IReadOnlyCollection<Guid>. 这可能是翻译失败的原因吗?
UPD2:将Ids类型更改为Guid[]或IEnumerable<Guid>没有帮助。同样的错误。
| 归档时间: |
|
| 查看次数: |
923 次 |
| 最近记录: |