我有一个 detailcollection
集合,其中每个细节都有
code, price, name
还有一个带有一些代码的字符串
string codes = "1,2,3";
我知道我可以使用 string.Split()
获取数组
string[] codesarray = codes.Split(',');
但是我怎样才能得到不在代码
中的产品呢?
// the idea I have, but I would not like to have a loop
for (int i = 0; i < codesarray.Length; i++)
{
detailcollection.Where(x => x.ope_idsku == codesarray[i])
}
我想要这样的东西:
detailcollection.Where(x => x.ope_idsku not in (codesarray))
最佳答案
不在codesarray
中的选择的详情集合项:
detailcollection.Where (x=> !codesarray.Contains(x.ope_idsku))
关于c# - "not in"的 Lambda 表达式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15574952/