Linq Aggregate on object and List

Posted by Kris-I on Stack Overflow See other posts from Stack Overflow or by Kris-I
Published on 2011-06-29T11:26:37Z Indexed on 2011/06/30 8:22 UTC
Read the original article Hit count: 209

Filed under:
|
|

I do this query with NHibernate:

    var test = _session.CreateCriteria(typeof(Estimation))
                .SetFetchMode("EstimationItems", FetchMode.Eager)
                .List();

An "Estimation" can have several "EstimationItems" (Quantity, Price and ProductId)

I'd like a list of "Estimation" with these constraints :

  1. One line by "Estimation" code on the picture (ex : 2011/0001 and 2011/0003)
  2. By estimation (means on each line) the number of "EstimationItems"
  3. By Estimation (means on each line) the total price (Quantity * Price) for each "EstimationItems"

I hope the structure will be clearer with the picture below.

Thanks,

enter image description here

enter image description here

© Stack Overflow or respective owner

Related posts about c#

Related posts about LINQ