开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜