使用 linq,我必须检查数组中是否存在行的值。
相当于sql查询:
WHERE ID IN (2,3,4,5)
我该怎么做?
最佳答案
.包含
var resultset = from x in collection where new[] {2,3,4,5}.Contains(x) select x
当然,对于你的简单问题,你可能会遇到类似的问题:
var resultset = from x in collection where x >= 2 && x <= 5 select x
关于c# - 相当于 SQL IN 运算符的 linq 是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2334327/