c# - "not in"的 Lambda 表达式?

标签 c# compact-framework lambda

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

相关文章:

c# - 如何将 int 数组 (int[]) 传递给 ASP.NET Core 中的 Get 方法

C# - 如何删除临时 Internet 文件

c# - 有关 .Net Compact Framework 开发的书籍

c# - 以编程方式删除 Windows Mobile 设备上的电子邮件和 SMS

c# - 通过 msi 文件在 Windows Mobile 中部署 .Net Compact Framework 应用程序

amazon-web-services - 通过 AWS API Gateway 和 Lambda 函数返回动态内容类型

c# - 带有格式提供程序的 Expression.ToString()

groovy - 带有 Groovy 'with' 闭包的重复 try-catch block ?

c# - 清理 C# 代码

C# Linq "Entity with the same key ' 0' already added."插入多行时