title: LINQ to DataSet Group By Multiple Columns - Method Syntax
body: <p>My question is identical to two previously asked questions</p>
  
  <p><a href="https://stackoverflow.com/questions/1225710/linq-to-dataset-multiple-group-by-on-a-data-table">LINQ TO DataSet: Multiple group by on a data table</a>, the only difference with this question is that I need to do that with Method Syntax.<br>
  and </p>
  
  <p><a href="https://stackoverflow.com/questions/1869001/linq-group-by-multiple-fields-syntax-help">LINQ Group By Multiple fields -Syntax help</a> - the difference with this question is that I need to do this using LINQ-to-DataSet. </p>
  
  <p>I'm trying to group the Customers by Country, with the result (expected) as below:</p>
  
  <pre><code>   COUNTRYCODE     CUSTOMERNAME
     USA             Microsoft   
     USA             IBM
     CAN             RIM
     CAN             Tim Horton
     GER             BMW
  </code></pre>
  
  <p>How do we do this?  Thank you.  </p>
  
  <p>EDIT: </p>
  
  <p>Here's the messy code I'm struggling with. </p>
  
  <pre><code>   var query = orders.AsEnumerable()
                      .GroupBy(t =&gt; new {CountryCode= t.Field&lt;string&gt;("CountryCode"), 
                                         CustomerName = t.Field&lt;string&gt;("CustomerName"), 
                                      (key, group)=&gt; new {Key1 = key.CountryCode, Key2=key.CustomerName})
                      .Select(t =&gt; new {t.Key1, t.Key2});
  </code></pre>