Skip to content

Commit 6ebe428

Browse files
committed
Added comment
1 parent 58ea7e2 commit 6ebe428

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

Griddly.Mvc/DynamicLinq.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public static IQueryable<T> Select<T>(this IQueryable source, string selector, p
6666
{
6767
return Select(source, typeof(T), selector, values) as IQueryable<T>;
6868
}
69-
69+
7070
public static IQueryable<T> OrderBy<T>(this IQueryable<T> source, string ordering, params object[] values)
7171
{
7272
return (IQueryable<T>)OrderBy((IQueryable)source, ordering, values);
@@ -148,6 +148,13 @@ public static int Count(this IQueryable source)
148148
}
149149

150150
// 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>
151158
public static object Aggregate(this IQueryable source, string function, string member)
152159
{
153160
if (source == null) throw new ArgumentNullException("source");
@@ -181,9 +188,9 @@ public static object Aggregate(this IQueryable source, string function, string m
181188
else
182189
{
183190
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);
187194

188195
return source.Provider.Execute(
189196
Expression.Call(

0 commit comments

Comments
 (0)