У меня следующий запрос
DetachedCriteria criteria = DetachedCriteria.For(typeof(Income))
.CreateAlias("Product", "p")
.SetProjection(
Projections.ProjectionList()
.Add(Projections.GroupProperty("Product"))
.Add(Projections.Sum("Quantity"))
);
что переводится в sql:
SELECT this_.Product_id as y0_,
sum(this_.Quantity) as y1_
FROM income this_
inner join products p1_
on this_.Product_id = p1_.Id
GROUP BY this_.Product_id
мой домен:
class Product
{
IList<Income> Incomes {get;set;}
}
class Income
{
Product Product {get;set;}
}
при итерации возвращенной коллекции у меня есть один запрос для каждой сущности Product.
Как я могу получить всю коллекцию в одном запросе?