title: C# Left join in LINQ
body: <p>Not sure how to convert the following sql into a LINQ expression. My db does use referential integrity and table Content is related to table Content_Training in a 1 to many relationship (ex: 1 content can have many content_trainings).</p>
  
  <pre><code>select c.ContentId, c.Name, ct.TrainingTypeId 
  from dbo.Content c left join dbo.ContentTraining ct on c.ContentId = ct.ContentId
  where c.ExpirationDate is not null
  order by ct.TrainingTypeId, c.Name
  </code></pre>
  
  <p>I have tried this, which seems to work. However, I am not certain about the usage of the "let" keyword.</p>
  
  <pre><code>var data = (from c in context.Contents
  let ct = ( from t in context.Content_Training where t.ContentId == c.ContentId
  select new { t.TrainingTypeId } ).FirstOrDefault()
  where c.ExpirationDate.HasValue
  orderby ct.TrainingTypeId, c.Name
  select new { c.ContentId, c.Name, ct.TrainingTypeId } ).ToList();
  </code></pre>