Empty group to create easy totals

This commit is contained in:
David Lebee 2018-10-21 16:15:59 -05:00
parent 019d34bf01
commit 49d9d92a4c

View File

@ -157,5 +157,16 @@ namespace PoweredSoft.DynamicLinq
var result = method.Invoke(null, new object[] {query}); var result = method.Invoke(null, new object[] {query});
return (long) result; 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;
}
} }
} }