title: Dynamic GroupBy Linq to SQL
body: <p>I am populating about 10 comboboxes by grouping the data in my database by the column name. So the combobox can be used to filter content.</p>
  
  <p>Heres my function </p>
  
  <pre><code>private void SetFilterDataSource(RadComboBox comboBox, string columnName)
  {
      var query = (from p in productContext.Products
                         where p.ProductRange != ""
                          group p by p.ProductRange into pGroup
                         select new
                         {
                             ProductRange = pGroup.Key
                         });
  
      comboBox.DataSource = query;
      comboBox.DataBind();
  }
  </code></pre>
  
  <p>At present this would be repeated 10 times for each combobox. So i was wondering if there was a way to make this dynamic based on a string that was passed to it?</p>