long[] items = { 3, 5, 8 };
var predicate = PredicateBuilder.False<TABLE2>();
foreach (long i in items)
{
long t = i;
predicate = predicate.Or(att => att.ID == t);
}
//TABLE2.Where(predicate).Dump(); //works like a charm
IQueryable query =
from t1 in TABLE1
where t1.TABLE2.AsQueryable().Any(predicate) //problem with this line
select a;
query.Dump();
更新
在LinqPad中使用LinqKit时,需添加对LinqKit.dll的引用,取消勾选包含PredicateBuilder,然后还需要在“附加命名空间导入”选项卡下添加LinqKit。