title: LINQ group by property as a parameter
body: <p>I have a list of objects that I want to query using LINQ. I want to be able to group them by a property.</p>
  
  <pre><code>var query = from item in expense
      orderby item.ExpenseTime descending
      group item by item.Location;
  
  var query = from item in expense
      orderby item.ExpenseTime descending
      group item by item.ExpenseType;
  
  var query = from item in expense
      orderby item.ExpenseTime descending
      group item by item.Person;
  </code></pre>
  
  <p>Is there a way to specify the property as an argument of a method?</p>
  
  <pre><code>public static void GetExpensesBy(List&lt;Expense&gt; expense, Property myGroupingProperty)
  {
      var query = from item in expense
                  orderby item.ExpenseTime descending
                  group item by item.myGroupingProperty;
  
      // ....
  }
  </code></pre>
  
  <p>Note that after the query there is code that is generic and does not care about the group.</p>