表示“不在”的Lambda表达式
本文关键字:Lambda 表达式 不在 表示 | 更新日期: 2023-09-27 18:05:15
我有一个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))