title: c # using linq to group by multiple columns in a datatable
body: <p>I have three columns in a datatable: string, DateTime, and decimal. I want to group by the string and decimal column, and for the rows grouped I want to sum the decimal values. I know how to do the sum part, but how do you group two different columns in a datatable?</p>
  
  <p>This is my code so far which doesn't work properly:</p>
  
  <pre><code>var newSort = from row in objectTable.AsEnumerable()
                group row by new {ID = row.Field&lt;string&gt;("resource_name"), time1 = row.Field&lt;DateTime&gt;("day_date")} into grp
                orderby grp.Key
                select new
                {
                   resource_name1 = grp.Key.ID,
                   day_date1 = grp.Key.time1,
                   Sum = grp.Sum(r =&gt; r.Field&lt;Decimal&gt;("actual_hrs"))
                };
  </code></pre>