title: LINQ to SQL: GroupBy() and Max() to get the object with latest date
body: <p>Consider a SQL Server table that's used to store events for auditing.</p>
  
  <p>The need is to get only that <em>latest entry</em> for each CustID. We want to get the entire object/row. I am assuming that a GroupBy() will be needed in the query. Here's the query so far:</p>
  
  <pre><code>var custsLastAccess = db.CustAccesses   
                          .Where(c.AccessReason.Length&gt;0)
                          .GroupBy(c =&gt; c.CustID)
  //                      .Select()
                          .ToList();
  // (?) where to put the c.Max(cu=&gt;cu.AccessDate) 
  </code></pre>
  
  <p><img src="https://imgur.com/oz5oj.png" alt="Custs Layout"></p>
  
  <p><strong>Question:</strong>
  How can I create the query to select the latest(the maximum <code>AccessDate</code>) record/object for each <code>CustID</code>?</p>