linq groupby

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Carel
    New Member
    • Nov 2009
    • 4

    linq groupby

    Hi all,

    If I have set of fields of which I use some for grouping and some for aggregating, how can I have other fields in the final step where the aggregating also takes place?

    Suppose there is also a t.c and a t.d in the input sequence that I want in the select new part, how to do that?
    Code:
    var output = 
    from t in input
    group t
    by new 
    {
    	w = t.a,
    	x = t.b
    }
    into s
    select new 
    {
    	w = s.Key.w,
    	x = s.Key.x,
    	a = s.Average(u => u.q)
    };
    ???
    Last edited by Frinavale; Dec 8 '09, 09:26 PM. Reason: Please post code in [code] ... [/code] tags. Added code tags.
Working...