title: linq with max() and join
body: <p>There is the linq statement I am using </p>
  
  <pre><code>            var renewalQuery = from r in crnnsupContext.Renewals
                                 from w in crnnsupContext.WorkPlaces
                                 join p in crnnsupContext.ProvStates on p.ProvinceStateID equals r.EmployerProvState
                                 where  r.RegNumber == _username &amp;&amp; r.PlaceOfWork == w.WorkID
                                 select r;
  </code></pre>
  
  <p>There is a <code>r.RenewalYear</code> which I want to get the latest year, so I tried something like</p>
  
  <pre><code>                var renewalQuery = from r in crnnsupContext.Renewals
                                 group r by r.RenewalYear into g
                                 from w in crnnsupContext.WorkPlaces
                                 join p in crnnsupContext.ProvStates on p.ProvinceStateID equals r.EmployerProvState
                                 where  r.RegNumber == _username &amp;&amp; r.PlaceOfWork == w.WorkID
                                 select g.max(r.RenewalYear);
  </code></pre>
  
  <p>obviously it doesn't work, does anyone know the correct grammar for this? thanks very much</p>