LINQ to SQL是什么而不是平等的?
例如
- select * from table in ( ...)
- and
- select * from table not in (..)
LINQ to sql中的上述语句相当于什么?
解决方法
您使用,< list> .Contains(< item>)
- var myProducts = from p in db.Products
- where productList.Contains(p.ProductID)
- select p;
或者您可以预定义列表:
- var ids = {1,2,3};
- var query = from item in context.items
- where ids.Contains( item.id )
- select item;
对于’NOT’的情况,只需添加’!’运算符在“包含”声明之前.