title: Join two tables with one to many relationship and pick latest from multiple side
body: <p>I have two tables: Patients and PatientVisits . A Patient can have many visits.
  There are corresponding Model classes in C#.</p>
  
  <p>How would I write a Linq query to get each Patient and it's latest visit date? </p>
  
  <p>The raw SQL which does this is:</p>
  
  <pre><code>select max(p."FirstName"), max(p."LastName"), max(pv."VisitDate")
  from "Patients" p 
  left outer join "PatientVisits" pv ON pv."PatientID" = p."ID" 
  group by p."ID"
  </code></pre>