title: How to create linq predicate with multiple nested "ands" and "ors"
body: <p>I am trying to dynamically create a linq expression at runtime using PredicateBuilder from <a href="http://www.albahari.com/nutshell/predicatebuilder.aspx" rel="nofollow noreferrer">http://www.albahari.com/nutshell/predicatebuilder.aspx</a>.</p>
  
  <p>I currently have a method that takes a list of criteria objects, and then parses those into multiple predicates much as described in this <a href="https://stackoverflow.com/questions/5904704/how-to-create-sql-nested-ands-inside-of-multiple-ors-using-linq">post</a>.</p>
  
  <p>So currently, my code supports the following scenario:</p>
  
  <pre><code>WHERE 
      ((a == &lt;val1&gt;) AND (b == &lt;val2&gt;) AND (c == &lt;val3&gt;))
  OR
      ((a == &lt;val4&gt;) AND (b == &lt;val2&gt;) AND (c == &lt;val3&gt;))
  </code></pre>
  
  <p>But I need it to work like this:</p>
  
  <pre><code>WHERE 
      ((a == &lt;val1&gt; OR a == &lt;val4&gt;) AND (b == &lt;val2&gt;) AND (c == &lt;val3&gt;))
  OR
      ((a == &lt;val7&gt;) AND (b == &lt;val5&gt;) AND (c == &lt;val6&gt;))
  </code></pre>
  
  <p>How can I make it so that I can "group" two "ORs" together so the logic flows properly?  I don't want "a OR a AND b AND c", I need "(a OR a) AND b and C".</p>