Class GroupedQuery<TKey, TSource>
Intermediate query produced by GroupBy<TKey>(Expression<Func<T, TKey>>). Not
directly executable — the only exit is Select<TResult>(Expression<Func<IGrouping<TKey, TSource>, TResult>>) which collapses
the groups back into a shaped result set. Calls inside the projection lambda
(g.Sum, g.Average, g.Count, g.Key, …) translate to SQL
aggregates against the current GROUP BY.
public sealed class GroupedQuery<TKey, TSource> where TSource : class, new()
Type Parameters
TKeyTSource
- Inheritance
-
GroupedQuery<TKey, TSource>
- Inherited Members
Methods
Select<TResult>(Expression<Func<IGrouping<TKey, TSource>, TResult>>)
Collapse groups into a shaped result. Inside projection, use
g.Key to reference the grouping key and g.Sum/Average/Min/Max/Count/Any
to aggregate rows. Everything translates to SQL — rows aren't materialized into
TSource first.
public ProjectedQuery<TSource, TResult> Select<TResult>(Expression<Func<IGrouping<TKey, TSource>, TResult>> projection)
Parameters
projectionExpression<Func<IGrouping<TKey, TSource>, TResult>>
Returns
- ProjectedQuery<TSource, TResult>
Type Parameters
TResult