title: LINQ query help please. Selecting most recent record for each FK
body: <p>Let's say I have a table that looks like this:</p>
  
  <pre><code>Id     CheckboxId     Selected     DateCreated
  1      1              1            1/1/2010
  2      2              1            1/2/2010
  3      1              0            1/3/2010
  4      3              1            1/4/2010
  5      3              0            1/5/2010
  </code></pre>
  
  <p>CheckboxId is a FK and the table is just a history of when the boxes are checked or unchecked.</p>
  
  <p>What I want to get is the most recent record for each CheckboxId. In the case of my demo table I want rows 2, 3, and 5. How would you accomplish this? Also I'm sure this is as easy as a "where" at the beginning of the query but if it could also be modified to only get records before a specified date that would be fantastic.</p>
  
  <p>I'm having trouble figuring out how I would write a query to do this in SQL and it's making a link query impossible. I'm sure it has to be a selection from a sub query of distinct checkboxIds coupled with a group by or something but my SQL just isn't that great.</p>
  
  <p>Many thanks for your help.</p>