[英]Lambda Expression for “not in”?
我有一个detailcollection
集合,每个细节都有
code, price, name
并带有一些代码的字符串
string codes = "1,2,3";
我知道我可以使用string.Split()
获取数组
string[] codesarray = codes.Split(',');
但是如何才能获得不在codes
产品?
// 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))
选定的详细信息收集项目,其中ID不在codesarray
:
detailcollection.Where (x=> !codesarray.Contains(x.ope_idsku))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.