title: How to select only several columns from GroupBy... First()
body: <p>I am trying to select &quot;highest&quot; licence user has per year.</p>
  <p>I started with:</p>
  <pre><code>var lic = _context.Licences
              .Where(l =&gt; l.MemberNumber == memberNumber) 
              .GroupBy(l =&gt; new { l.LicenceYear }
              (key, g) =&gt; g.OrderByDescending(l =&gt; l.ProfessionalTitleId)
              .First());
  </code></pre>
  <p>and it works.</p>
  <p>However it always returns ALL columns from Licence which I don't want. Moreover I would like to select some child property like <code>l.Title.TitleNumber</code>, but no matter where I put <code>.Select(l =&gt; new {l.LicenceNumber, l.Title.TitleNumber})</code> generated sql query selects all columns from Licences, and only from Licences.</p>
  <p>I have also tried</p>
  <pre><code>var lic = _context.Licences
              .Where(l =&gt; l.MemberNumber == User.GetMemberNumber())            
              .GroupBy(l =&gt; new { l.LicenceYear },
              l =&gt; new { l.Title.TitleNumber, l.LicenceYear, l.LicenceNumber, l.Title.ProfessionalTitleId },
              (key, g) =&gt; g.OrderByDescending(l =&gt; l.ProfessionalTitleId)
              .First());
  </code></pre>
  <p>Interestingly enough it properly creates ROW_NUMBER() using <code>ProfessionalTitleId</code> from <code>Title</code> but still selects all columns from Licences.</p>
  <p>So, how to modify query to select only some columns?</p>