title: LINQ Join to get latest record from 2nd table
body: <p>Problem:</p>
  
  <p>Their are two tables TableEmails and TableSentEmailRecords. So when ever emails are sent out, a records, such as sent time etc are stored in TableSentEmailRecords.</p>
  
  <p>I want to do a LINQ query, which gets me columns of TableEmails PLUS a "SentDate" column from TableSentEmailRecords that displays the latest date that email was sent out.</p>
  
  <p>I tried this:</p>
  
  <pre><code>List&lt;CustomEmail&gt; emails = new List&lt;CustomEmail&gt;();
  
  var query = from c in db.TableEmails 
              join o in db.TableSentEmailRecords on c.EmailId equals o.EmailId
                          select new CustomEmail
                          {
                              EmailName = c.EmailName,
                              EmailId= c.EmailId,
                              EmailDescription = c.EmailDescription,
                              LastDateEmailSentOut = o.SentDate
                          };
  
  emails = query.ToList();
  </code></pre>
  
  <p>but this not necessarily get the latest record of that particular email from TableSentEmailRecords  table.</p>
  
  <p>Any Ideas ???</p>