我有一个使用 NHibernateSession.Query<T>方法的 linq 查询,我在这个查询中获取了一些复杂的属性和集合属性。我想知道,我怎样才能添加一个带有IN运算符的条件int[]?看我的代码:
public IEnumerable<Product> GetProducts(int[] idCategories)
{
// how to add IN condition here or a subquery
var query = Session.Query<Product>()
.Where(?????)
.Fetch(x=>x.Category)
.FetchMany(x=>x.Status).ThenFetch(x=>x.Item);
return query.ToList();
}
我有另一种查询方法来获取它int[],我想在这里应用它,或者是否有任何方法可以在IN运算符上添加这个子查询,我真的很感激!
OBS:如有必要,我可以转换int[]为。List<int>
编辑
我int[]通过如下查询得到了这个:
return session.Query<Category>.Where(...).Select(x => x.Id).ToArray();
我的第二个问题是,如何将此查询添加为子查询以按类别过滤?
谢谢!