Linq nhibernate groups and joins
Consider a simple order example (should get the title and quantity ordered for each product): (note - grouping by Title is not a good answer)
var orderQuery =
session.Query<OrderLine>()
.Where(ol => ol.Quantity > 0)
.GroupBy(ol => ol.Product.Id)
.Select(x => new
{
productId = x.Key,
quantity = x.Sum(i => i.Quantity)
});
var query =
session.Query<Product>()
.Join(orderQuery,
开发者_运维问答 x => x.Id,
x => x.productId,
(x, p) => new { x.FeedItem.Title, p.quantity });
However, this throws a
could not resolve property: Key of: OrderLine
any ideas?
Try to create your query using QueryOver and Projections Sample
精彩评论