title: How to create a join in an expression tree for LINQ?
body: <p>I have a Task object that has a collection of Label objects ... in the database the tables are called Task and Label.  </p>
  
  <p>There are a variety of ways to search for a Task, so using LINQ, I construct my LINQ query in an expression tree ... similar to the below code sample:</p>
  
  <pre><code>IQueryable&lt;Data.Task&gt; query = ctx.DataContext.Tasks;    
  
  if (criteria.Number &gt; 0)    
      query = query.Where(row =&gt; row.Number == criteria.Number);  
  
  if (criteria.CustomerId != Guid.Empty)
      query = query.Where(row =&gt; row.Project.CustomerId == criteria.CustomerId);
  
  if (criteria.ProjectId != Guid.Empty)
      query = query.Where(row =&gt; row.ProjectId == criteria.ProjectId);
  
  var data = query.Select(row =&gt; TaskInfo.FetchTaskInfo(row));
  
  this.AddRange(data); 
  </code></pre>
  
  <p>This works great ... but now I would like to search for Tasks with a specific Label, for example, accounting or feature-request.</p>
  
  <p>I am able to do this in LINQPad from a complete query:</p>
  
  <pre><code>from t in Tasks
  join l in Labels on t.TaskId equals l.SourceId 
  where l.Name == "accounting"
  select t
  </code></pre>
  
  <p>Is there anyway to do this using an expression tree? I'm stuck! Any help would be greatly appreciated!</p>