I have a linq query with NHibernate using Session.Query<T>
method and I in this query I Fetch some complex properties and collection properties. I would like to know, how can I add an condition with IN
operator from an int[]
? Look my code:
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();
}
I have another method doing a query to get this int[]
and I would like to apply it here, or if is there any way to add this subquery on the IN
operator, I really appreciate!
OBS: I could convert int[]
to List<int>
if its necessary.
Edits
I got this int[]
by a query like:
return session.Query<Category>.Where(...).Select(x => x.Id).ToArray();
My second question is, how could I add this query as a subquery to filter by category?
Thank you!