相关疑难解决方法(0)

Dictionary Keys.Contains vs. ContainsKey:它们在功能上是否相同?

我很想知道这两个在所有情况下是否在功能上是等效的.

是否有可能通过更改字典的默认比较器,这两者在功能上会有所不同?

而且,Keys.Contains几乎不能保证更慢?

c# performance dictionary equivalence

20
推荐指数
2
解决办法
1万
查看次数

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
查看次数