use*_*567 0 c# comparison ienumerable list
我Ienumerable<int> Temp1;来自DB
和其他List<entity> Temp2;具有属性Id和名称.
我想compare Temp1 & Temp2(Id)找到匹配的值并将其放在List中.
实现这个的最佳方法是什么?
谢谢
var sameIds = Temp2.Select(x=>x.Id).Intersect(Temp1);
Run Code Online (Sandbox Code Playgroud)
首先只选择Id为新,IEnumerable<int>然后IEnumerable<int>将其与当前可用的相交,将为您提供匹配的ID