开发者

"Select NOT IN" clause in Linq to Entities

开发者 https://www.devze.com 2022-12-28 00:12 出处:网络
Is there a way to use the \"NOT IN (select XXX...)\" clause in Linq to E开发者_高级运维ntities?

Is there a way to use the "NOT IN (select XXX...)" clause in Linq to E开发者_高级运维ntities?

All the questions I found were regarding a list of objects (IN (1,2,3)) but I want to generate a query with the following syntax:

select * from table1 where field1 not in (select subfield from subtable)  

Be aware that this is Linq to Entities and not Linq to Sql...

Is it possible?

Thanks!


Like this:

from c in db.Customers
where !db.Products.Any(p => p.ProductID == c.ProductID)
select c;
0

精彩评论

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