如何在linq中动态的实现in?
var queryResult = from p in db.Productswhere (new int?[] {1,2}).Contains(p.CategoryID)
select p;
我网上查到的资料在in中都是写死的,但是如果我想传一个List<int> IDS的集合,让查询出来的订单号包含在这个集合中,类似 select ID from a where ID in(IDS )这种效果的该怎么办? --------------------编程问答--------------------
List<int> IDS;--------------------编程问答-------------------- http://blog.csdn.net/q107770540/article/details/5387946 --------------------编程问答-------------------- List<int> lst=new List<int>(){1,2};<-这里你随意变
var queryResult = from p in db.Products
where IDS.Contains(p.CategoryID)
select p;
from p in db.Products
where lst.Contains(p.CategoryID)
select p;
补充:.NET技术 , C#