title: LINQ to SQL and Join two tables with OR clause
body: <p>Let's say I have Plans and Documents</p>
  
  <pre><code>Dim myPlans = _context.Plans.Where(predicate1)
  Dim myDocuments = _context.Documents.Where(predicate2)
  </code></pre>
  
  <p>I have structured the where clause for each using PredicateBuilder. So, myPlans and myDocuments have a correct SQL statement.</p>
  
  <p>What I'd like to do is join these two tables into one linq statement. The problem I'm having is that, by default the AND condition is joining the where clauses.</p>
  
  <p>myPlans Where clause : (p.name like "%test%" AND p.name like "%bed%") OR (p.description like "%test%" AND p.description like "%bed%")</p>
  
  <p>myDocuments Where clause : (d.name like "%test%" AND d.name like "%bed%") OR (d.description like "%test%" AND d.description like "%bed%")</p>
  
  <p>When I combine the two the <b>desired</b> result Where clause is:<br>
  Where (d.ID = p.ID) AND
  (myplans where clause above) <b> OR </b> (mydocument where clause above). Meaning, I'd like the two where clauses in each of the tables to be "or" instead of "And".</p>
  
  <p>The current result where clause is:
  Where (d.ID = p.ID) AND
  (myplans where clause above) <b> AND</b> (mydocument where clause above). Meaning, I'd like the two where clauses in each of the tables to be "or" instead of "And".</p>
  
  <p>I'm forming the statement like this:</p>
  
  <pre><code>Dim test = From d in myDocuments _
             Join p in MyPlans on d.ID Equals p.ID _
             Select d.Name, p.Name
  </code></pre>