title: In this particular example, how can I get the first record in each group?
body: <p>In the code below, how can I get the first record in each group? My real query is more complex and I have to create the anonymous types, then use LoadDataRow on the dtResult table that I have created. I need to do this so I can use the CopyToDataTable functionality on my result:</p>
  
  <pre><code>           var results =
              (from cust in customers
               join invoice in invoices
               on
                   new
                   {
                       Prefix = cust.Field&lt;string&gt;("Prefix"),
                       CustNumb = cust.Field&lt;int&gt;("CustomerNumber")),
                       Suffix = cust.Field&lt;int&gt;("Suffix"))
                   }
               equals
                   new
                   {
                       Prefix = invoice.Field&lt;string&gt;("Prefix"),
                       CustNumb = invoice.Field&lt;int&gt;("CustomerNumber"),
                       Suffix = invoice.Field&lt;int&gt;("Suffix")
                   }
               group cust by new
               {
                   Prefix = cust["Prefix"],
                   CustomerNumber = cust["CustomerNumber"],
                   Suffix = cust["Suffix"],
                   Name = cust["Name"],
                   Address = cust["Address"]
               }
               into groups
               orderby groups.Key.Name
               // how do I get only the first record of each group?
               select dtResult.LoadDataRow(
                  new object[]
                  {
                      groups.Key.Prefix,
                      groups.Key.CustomerNumber,
                      groups.Key.Suffix,
                      groups.Key.Name,
                      groups.Key.Address
                  }, false) 
               );
  </code></pre>