linq in和not in

LINQ的IN:

var queryResult = from p in db.Products
where (new int?[] {1,2}).Contains(p.CategoryID)
select p;

LINQ的NOT IN:

var queryResult = from p in db.Products
where ! (new int?[] {1,2}).Contains(p.CategoryID)
select p;

 

posted @ 2016-04-23 10:52  Leo的日记本  阅读(124)  评论(0编辑  收藏  举报