@@ -66,7 +66,7 @@ public static IQueryable<T> Select<T>(this IQueryable source, string selector, p
66
66
{
67
67
return Select ( source , typeof ( T ) , selector , values ) as IQueryable < T > ;
68
68
}
69
-
69
+
70
70
public static IQueryable < T > OrderBy < T > ( this IQueryable < T > source , string ordering , params object [ ] values )
71
71
{
72
72
return ( IQueryable < T > ) OrderBy ( ( IQueryable ) source , ordering , values ) ;
@@ -148,6 +148,13 @@ public static int Count(this IQueryable source)
148
148
}
149
149
150
150
// http://stackoverflow.com/questions/17490080/how-to-do-a-sum-using-dynamic-linq
151
+ /// <summary>
152
+ /// Dynamically runs an aggregate function on the IQueryable.
153
+ /// </summary>
154
+ /// <param name="source">The IQueryable data source.</param>
155
+ /// <param name="function">The name of the function to run. Can be Sum, Average, Min, Max.</param>
156
+ /// <param name="member">The name of the property to aggregate over.</param>
157
+ /// <returns>The value of the aggregate function run over the specified property.</returns>
151
158
public static object Aggregate ( this IQueryable source , string function , string member )
152
159
{
153
160
if ( source == null ) throw new ArgumentNullException ( "source" ) ;
@@ -181,9 +188,9 @@ public static object Aggregate(this IQueryable source, string function, string m
181
188
else
182
189
{
183
190
aggregateMethod = typeof ( Queryable ) . GetMethods ( ) . SingleOrDefault (
184
- m => m . Name == function
185
- && m . GetGenericArguments ( ) . Length == 2
186
- && m . IsGenericMethod ) ;
191
+ m => m . Name == function
192
+ && m . GetGenericArguments ( ) . Length == 2
193
+ && m . IsGenericMethod ) ;
187
194
188
195
return source . Provider . Execute (
189
196
Expression . Call (
0 commit comments