Lambda表达式的"不"? [英] Lambda Expression for "not in"?
本文介绍了Lambda表达式的"不"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以及我有一个集合,因为它
detailcollection
其中的每一个细节都
代码,价格,名称
现在我有一些代码字符串
串码=1,2,3
我知道我可以使用拆分
$ b
的String [] = codesarray codes.split('')
那我怎么才能让产品不代码
/ *这是想法,我有,但我不希望有一个循环* /
的for(int i = 0; I< codesarray.count;我++)
{
detailcollection.Where(X => x.ope_idsku == codesarray [I])
}
我想的东西,因为它
detailcollection.Where(X => x.ope_idsku没有( codesarray))
解决方案
选择的细节藏品这ID不在 codesarray
:
detailcollection.Where(X => !codesarray.Contains(x.ope_idsku))
well i have a collection as it
detailcollection
which every detail have
code,price,name
now i have a string with some codes
string codes="1,2,3"
i know i can get a array using split
string[] codesarray=codes.split(',')
then how can i get products not in codes
/*it is the idea i have, but i would not like to have a loop*/
for(int i=0; i< codesarray.count;i++)
{
detailcollection.Where (x=> x.ope_idsku ==codesarray[i])
}
i would like something as it
detailcollection.Where (x=> x.ope_idsku not in (codesarray))
解决方案
Selected details collection items which ids are not in codesarray
:
detailcollection.Where (x=> !codesarray.Contains(x.ope_idsku))
这篇关于Lambda表达式的"不"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文