相关疑难解决方法(0)

linq to entity framework:在查询中使用字典

我有:

Dictionary<int, List<int>> dict = new ...
var a = SomeEntity.Where(f => dict[f.key].Contains(f.someValue)) 
Run Code Online (Sandbox Code Playgroud)

这会产生错误

 LINQ to Entities does not recognize the method 'System.Collections.Generic.List`1[System.Int32] get_Item(Int32)' method
Run Code Online (Sandbox Code Playgroud)

与列表一起工作:

List<int> l = new ...
var a = SomeEntity.Where(f => l.Contains(f.someValue))
Run Code Online (Sandbox Code Playgroud)

因此linq对EF的这种限制还是我错过了什么?

linq entity-framework

6
推荐指数
1
解决办法
5806
查看次数

标签 统计

entity-framework ×1

linq ×1