title: Left join in Linq?
body: <p>There are a lot of questions on SO already about Left joins in Linq, and the ones I've looked at all use the <code>join</code> keyword to achieve the desired end.</p>
  
  <p>This does not make sense to me.  Let's say I have the tables <code>Customer</code> and <code>Invoice</code>, linked by a foreign key <code>CustomerID</code> on <code>Invoice</code>.  Now I want to run a report containing customer info, plus any invoices.  SQL would be:</p>
  
  <pre><code>select c.*, i.*
    from Customer c
    left join Invoice i on c.ID = i.CustomerID
  </code></pre>
  
  <p>From what I've seen of the answers on SO, people are mostly suggesting:</p>
  
  <pre><code>var q = from c in Customers
          join i in Invoices.DefaultIfEmpty() on c.ID equals i.CustomerID 
          select new { c, i };
  </code></pre>
  
  <p>I really don't understand how this can be the only way.  The relationship between <code>Customer</code> and <code>Invoice</code> is already defined by the LinqToSQL classes; why should I have to repeat it for the <code>join</code> clause?  If I wanted an inner join it would simply have been:</p>
  
  <pre><code>var q = from c in Customers
          from i in c.Invoices
          select new { c, i };
  </code></pre>
  
  <p>without specifying the joined fields!</p>
  
  <p>I tried:</p>
  
  <pre><code>var q = from c in Customers
          from i in c.Invoices.DefaultIfEmpty()
          select new { c, i };
  </code></pre>
  
  <p>but that just gave me the same result as if it were an inner join.</p>
  
  <p>Is there not a better way of doing this?</p>