Skip to content

Commit

Permalink
Empty group to create easy totals
Browse files Browse the repository at this point in the history
  • Loading branch information
David Lebee committed Oct 21, 2018
1 parent 019d34b commit 49d9d92
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions PoweredSoft.DynamicLinq/Extensions/QueryableExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,16 @@ public static long LongCount(this IQueryable query)
var result = method.Invoke(null, new object[] {query});
return (long) result;
}

public static IQueryable EmptyGroupBy(this IQueryable queryable, Type underlyingType)
{
var parameter = Expression.Parameter(underlyingType);
var genericMethod = Constants.GroupByMethod.MakeGenericMethod(underlyingType, typeof(bool));
var trueConstant = Expression.Constant(true);
var lambda = Expression.Lambda(trueConstant, parameter);
var groupByExpression = Expression.Call(genericMethod, queryable.Expression, lambda);
var result = queryable.Provider.CreateQuery(groupByExpression);
return result;
}
}
}

0 comments on commit 49d9d92

Please sign in to comment.