开发者

LINQ Query to filter DTO

开发者 https://www.devze.com 2022-12-31 11:50 出处:网络
I have an array...and I need to exclude all the items in this array of string from the masterList.customField as shown below

I have an array...and I need to exclude all the items in this array of string from the masterList.customField as shown below

string[] excludeItem = {"a","b","c"};

CustomDTO[] masterLis开发者_开发百科t = service.LoadMasterList();

masterList.Where(c=> masterList.customField NOT IN excludeItem

How do I achieve the NOT IN part above?


Assuming customField is a string:

masterList.Where(c => !excludeItem.Contains(c.customField));


Or, as a LINQ query:

var x = from c in masterList
        where !excludedItem.Contains(c.CustomField)
        select c;
0

精彩评论

暂无评论...
验证码 换一张
取 消