title: How to dynamically build and return a linq predicate based on user input
body: <p>Getting a bit stuck on this. Basically I have a method that I want to return a predicate expression that I can use as a Where condition. 
  I think what I need to do is similar to this: <a href="http://msdn.microsoft.com/en-us/library/bb882637.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/bb882637.aspx</a> but I'm a bit stuck as to what I need to do. </p>
  
  <p>Method:</p>
  
  <pre><code>private static Expression&lt;Func&lt;Conference, bool&gt;&gt; GetSearchPredicate(string keyword, int? venueId, string month, int year)
  {
      if (!String.IsNullOrEmpty(keyword))
      {
          // Want the equivilent of .Where(x =&gt; (x.Title.Contains(keyword) || x.Description.Contains(keyword)));
      }
      if (venueId.HasValue) 
      {
          // Some other predicate added...
      }
  
      return ??
  
  }
  </code></pre>
  
  <p>Example Usage:</p>
  
  <pre><code>var predicate = GetSearchPreducate(a,b,c,d);
  var x = Conferences.All().Where(predicate);
  </code></pre>
  
  <p>I need this separation so that I can pass my predicate into my repository and use it in other places.</p>