title: How to do joins in LINQ on multiple fields in single join
body: <p>I need to do a LINQ2DataSet query that does a join on more than one field (as</p>
  
  <pre><code>var result = from x in entity
  join y in entity2 
         on x.field1 = y.field1 
  and 
            x.field2 = y.field2
  </code></pre>
  
  <p>I have yet found a suitable solution (I can add the extra constraints to a where clause, but this is far from a suitable solution, or use <a href="https://stackoverflow.com/questions/345427/linq-to-sql-join-multiple-columns-from-the-same-table">this</a> solution, but that assumes an equijoin).</p>
  
  <p>Is it possible in LINQ to join on multiple fields in a single join?</p>
  
  <p><strong>EDIT</strong></p>
  
  <pre><code>var result = from x in entity
               join y in entity2
               on new { x.field1, x.field2 } equals new { y.field1, y.field2 }
  </code></pre>
  
  <p>is the solution I referenced as assuming an equijoin above.</p>
  
  <p>Further <strong>EDIT</strong></p>
  
  <p>To answer criticism that my original example was an equijoin, I do acknowledge that, My current requirement is for an equijoin and I have already employed the solution I referenced above.</p>
  
  <p>I am, however, trying to understand what possibilities and best practices I have / should employ with LINQ. I am going to need to do a Date range query join with a table ID soon, and was just pre-empting that issue, It looks like I shall have to add the date range in the where clause.</p>
  
  <p>Thanks, as always, for all suggestions and comments given</p>