【问题标题】:Lambda Expression for "not in"?“不在”的 Lambda 表达式?
【发布时间】:2018-05-17 18:32:31
【问题描述】:

我有一个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))

【问题讨论】:

    标签: c# compact-framework lambda


    【解决方案1】:

    选中的详情集合项id不在codesarray中:

    detailcollection.Where (x=> !codesarray.Contains(x.ope_idsku))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-06-21
      • 2013-07-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多