title: How to select MAX in a sub query in Linq to Sql
body: <p>Given the following data, how does one select only the latest version for each item using LINQ?</p>
  
  <pre><code>ItemId, Version
  ===================
  A, 1
  A, 2
  A, 3
  B, 8
  B, 9,
  C, 10
  C, 11
  </code></pre>
  
  <p>The desired results are:</p>
  
  <pre><code>A, 3
  B, 9
  C, 11
  </code></pre>
  
  <p>In TSQL, I would do something like so:</p>
  
  <pre><code>SELECT * FROM MyTable AS Tbl1
  
  WHERE Tbl1.Version = 
  
  (SELECT MAX(Version) 
  FROM MyTable 
  WHERE MyTable.ItemId = Tbl1.ItemId)
  </code></pre>