title: c# linq filter group by max composite key
body: <p>I have a linq query:</p>
  <pre><code> var reports = await dbContex.ShoppingListPatientReports
                               .Where(report =&gt; patientIds.Contains(report.PatientId))
                               .GroupBy(report =&gt; new { report.PatientId, RecentDate = DbFunctions.TruncateTime(report.DateCreated) })
                               .OrderByDescending(g =&gt; g.Key)
                               .ToListAsync();
  </code></pre>
  <p>it returns groups sorted in descending order by the composite key (PatientId, RecentDate).
  Keys:</p>
  <pre><code>10004, 2021-02-03
  10004, 2021-01-01
  10004, 2021-02-02
  10002, 2021-01-05
  10002, 2021-01-06
  </code></pre>
  <p>can I somehow take only the groups with the largest key (PatientId, RecentDate)
  i.e groups with most recent dates (In this example, the result should be two groups):</p>
  <pre><code>10004, 2021-02-03
  10002, 2021-01-06 
  </code></pre>