title: Linq linq-to-entities add join if condition is met
body: <p>I am quite new to c# and EF, and i could not find an answer for the following question, forgive me should i have overlooked one.</p>
  
  <p>I want to join a "main query" query1 with several "optional querys" which go to different tables in the same model, how am i supposed to achieve that?</p>
  
  <p>If i try to use the Join() method, it works as long as i do this:</p>
  
  <pre><code>var query = query1.Join(query2 [...]);
  </code></pre>
  
  <p>but when trying something like</p>
  
  <pre><code>query = query1;
  
  if (condition_is_met)
  {
      query = query.Join(query2 [...]);
  }
  </code></pre>
  
  <p>i receive an error </p>
  
  <blockquote>
    <p>Cannot implicitly convert type '<code>System.Linq.IQueryable&lt;AnonymousType#1&gt;</code>' to '<code>System.Collections.Generic.IEnumerable&lt;someentity&gt;</code>'. An explicit conversion exists (are you missing a cast?)</p>
  </blockquote>
  
  <p>How can i avoid this error, and/or is there actually a way to add joins if a condition is met?</p>
  
  <p>Thanks in advance and sorry for the (i fear dumb) question.</p>