title: LINQ : Group by Multiple Columns with Maximum for one column
body: <p>I have query below in SQL. Tried using different options in linq to get the exact         matching result from SQL to my Center code, here is my code using linq. </p>
  
  <p>But could not get it.</p>
  
  <p>SQL query is (which gives correct result)</p>
  
  <pre><code>Select prdCode, Max(prdID) from products 
      GROUP BY prdCode
      order by prdCode
  </code></pre>
  
  <p>Tried below in linq</p>
  
  <pre><code>from prd in Entities.Products
      where prd.prdEnabled == true
      group prd by new { prd.prdCode, prd.prdID } into gcs 
      select new { prdID = gcs.Key.prdID, prdCode = gcs.Key.prdCode }
  </code></pre>
  
  <p>Thanks in advance.</p>