假设有一串以逗号分隔的文本值,就像一个数组:
var excludelist ="apples,oranges,grapes,pears";
排除列表值可能来自对数据库中表的查询。
假设一个查询,其中我们想要返回所有行,除了那些名为 Fruit 的字段包含排除列表中的任何项目的行。
var qry = from s in context.Groceries.Where(s => s.Fruit(here is where we need to exclude the items??) join u in context.Users on s.Owner equals u.User_ID
有人可以提供示例链接到 SQL 答案吗?
最佳答案
你试过Except
了吗?
var qry = from s in context.Groceries.Except(excludelist)...
到 SQL 的链接有 CONTAINS
(和!CONTAINS)
where !excludelist.Contains(i)
select i;
关于c# - EXCEPT 运算符是否可以排除列包含数组中数据的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10778177/