title: LINQ PredicateBuilder multiple OR starting with PredicateBuilder.True<>
body: <p>I have an entity like this:</p>
  
  <pre><code>public class Product()
  {
      public string Name { get; set; }
  }
  </code></pre>
  
  <p>I want to implement a search for keywords on the <code>Name</code> property so that they're OR'ed. In other words, a search for:</p>
  
  <blockquote>
    <p>spoon knife fork</p>
  </blockquote>
  
  <p>will search for <em>spoon</em> <strong>or</strong> <em>knife</em> <strong>or</strong> <em>fork</em> in the <code>Name</code> property. I introduced a new method for <code>PredicateBuilder</code> on <code>Product</code> that looks like this:</p>
  
  <pre><code>public static Expression&lt;Func&lt;Product, bool&gt;&gt; ContainsKeywords(params string[] keywords)
  {
      var predicate = PredicateBuilder.True&lt;Product&gt;();
  
      foreach (var keyword in keywords)
      {
          var temp = keyword;
          predicate = predicate.Or(x =&gt; x.Name.Contains(temp));
      }
  
      return predicate;
  }
  </code></pre>
  
  <p>And I'm using it like this in one of my methods for a web service:</p>
  
  <pre><code>var keywords = Request.QueryString["q"].Split(' ');
  var products = Repo.GetAll&lt;Product&gt;(); // get all the products from the DB
  products = products.Where(Product.ContainsKeywords(keywords));
  </code></pre>
  
  <p>The problem I'm running into is that the user may choose not to do a keyword search, in which case the <code>keywords</code> array will be empty. If I start with <code>PredicateBuilder.True&lt;Product&gt;()</code>, I get a list of all <code>Products</code>, regardless of what keywords I put in. If I start with <code>PredicateBuilder.False&lt;Product&gt;()</code>, it works if the user inputs keywords, but if not, then the return list is empty because everything matched <code>false</code>.</p>
  
  <p>How do I fix this in order to get my desired behavior, which is to return a list of all <code>Products</code> if no keyword was provided, and return a list of only the <code>Products</code> that matches the keywords if they were provided? I know I can do a check to see if the keywords array is empty before I do any processing, but if at all possible, I'd like <code>PredicateBuilder</code> to handle this case automatically.</p>