假设我们有一个IQueryable<T>
. 该Where
子句可以按单个 ID 值进行过滤,但是如何IQueryable
根据 ID 列表返回一个?
[TestMethod]
public void TestIQueryableWithList()
{
int ID1 = 1;
List<int> IDs = new List<int> { 1, 3, 4, 8 };
using (var db = new SellooEntities())
{
// works fine as single value
var iq = db.tblSearches.Where(x => x.seaUserId == ID1);
// how can i do it to check for all the IDs ??
foreach(int ID in IDs)
{
// this obviously wont work
var iq = db.tblSearches.Where(x => x.seaUserId == ID);
}
}
}