title: How to write group by query in dynamic linq query
body: <p>I am struggling to write 'Group by query' in dynamic linq query.</p>
  
  <pre><code>public IEnumerable&lt;DashboardReport&gt; GetDashTransactionsReports(string dimensionColumn)
      {
          var result = (from t in _dashboardContext.GetTransactionsReports()
                        group t by t.DimensionTransactionYear
                            into g
                            select new DashboardReport()
                            {
                                Name = g.Key,
                                Value = g.Sum(s =&gt; s.MeasureTotal)
                            }).ToList();
  
          var resultList = _dashboardContext.GetTransactionsReports().AsQueryable().GroupBy("TransactionMonth", "DashTransaction", null).Select("TransactionMonth");
  
  
          return result;
  
      }
  </code></pre>
  
  <p>"result" is used normal 'GroupBy' query. I'm turning it to dynamic way as "resultList" where I am struggling. Any idea ? </p>
  
  <p>I am using the following Dynamic Linq's Group by method:</p>
  
  <pre><code>public static IQueryable GroupBy(this IQueryable source, string keySelector, string elementSelector, params object[] values)
      {
          if (source == null) throw new ArgumentNullException("source");
          if (keySelector == null) throw new ArgumentNullException("keySelector");
          if (elementSelector == null) throw new ArgumentNullException("elementSelector");
          LambdaExpression keyLambda = DynamicExpression.ParseLambda(source.ElementType, null, keySelector, values);
          LambdaExpression elementLambda = DynamicExpression.ParseLambda(source.ElementType, null, elementSelector, values);
          return source.Provider.CreateQuery(
              Expression.Call(
                  typeof(Queryable), "GroupBy",
                  new Type[] { source.ElementType, keyLambda.Body.Type, elementLambda.Body.Type },
                  source.Expression, Expression.Quote(keyLambda), Expression.Quote(elementLambda)));
      }
  </code></pre>