我有一个数组......我需要从masterList.customField
中排除此数组字符串中的所有项目,如下所示
string[] excludeItem = {"a","b","c"};
CustomDTO[] masterList = service.LoadMasterList();
masterList.Where(c=> masterList.customField NOT IN excludeItem
如何实现上面的NOT IN部分?
答案 0 :(得分:3)
假设customField是一个字符串:
masterList.Where(c => !excludeItem.Contains(c.customField));
答案 1 :(得分:0)
或者,作为LINQ查询:
var x = from c in masterList
where !excludedItem.Contains(c.CustomField)
select c;