title: Get the first record of a group in LINQ?
body: <p><strong>Summary: How to get top 1 element in <em>ordered</em> groups of data</strong></p>
  
  <p>I am trying to group by a CarId field , and then within each group, I want to sort on a DateTimeStamp field descending.  The desired data would be for each Car give me the latest DateTimeStamp and only that 1 in the group.</p>
  
  <p>I can get to this point, but having problems taking the top 1 off of the group and ordering the group by DateTimeStamp desc.</p>
  
  <p>Here is what I have <em>after the first group operation</em>:</p>
  
  <pre><code>group 1
  ------------------------
  CarId  DateTimeStamp 
  1      1/1/2010
  1      1/3/2010
  1      3/4/2010
  
  group 2
  ------------------------
  CarId  DateTimeStamp 
  2      10/1/2009
  2      1/3/2010
  2      9/4/2010
  </code></pre>
  
  <p>what I would desire <em>only the top 1 in an ordered group</em></p>
  
  <pre><code>    group 1
      ------------------------
      CarId  DateTimeStamp 
      1      3/4/2010
  
      group 2
      ------------------------
      CarId  DateTimeStamp 
      2      9/4/2010
  </code></pre>
  
  <p><strong>Brickwall:</strong> Where I get stopped, is needing the CarId and DateTimeStamp in the group by clause, in order to later sort by the DateTimeStamp.  Maybe the sorting of the date should be done in a separate function, not sure.</p>