title: How does PredicateBuilder work
body: <p>C# in a Nutshell has a free class called PredicateBuilder which constructs LINQ predicates piece by piece available <a href="http://www.albahari.com/nutshell/predicatebuilder.aspx" rel="noreferrer">here</a>.  Here's an extract of the method which adds a new expression to the predicate.  Could someone explain it?  (I have seen <a href="https://stackoverflow.com/questions/5301875/how-does-this-predicatebuilder-class-work?rq=1">this question</a>, I don't want a general answer like there.  I am looking for a specific explanation of how Expression.Invoke and Expression.Lambda build the new expression).</p>
  
  <pre><code>public static Expression&lt;Func&lt;T, bool&gt;&gt; And&lt;T&gt; (this Expression&lt;Func&lt;T, bool&gt;&gt; expr1,
                                                       Expression&lt;Func&lt;T, bool&gt;&gt; expr2)
  {
      var invokedExpr = Expression.Invoke (expr2, expr1.Parameters.Cast&lt;Expression&gt; ());
      return Expression.Lambda&lt;Func&lt;T, bool&gt;&gt;
          (Expression.AndAlso (expr1.Body, invokedExpr), expr1.Parameters);
  }
  </code></pre>