title: Expression builder function for String.Contains and string[]
body: <p>I'm having a hard time creating an expression builder function to pass to a query for NHibernate repository.</p>
  
  <p>Basically what I want to be able to do is build a query from various object properties (strings) and compare their value to values in an array. Also be able to add other query sentences.</p>
  
  <p>Something like </p>
  
  <pre><code>public static Expression&lt;Func&lt;TElement, bool&gt;&gt; BuildOrExpression&lt;TElement, TValue&gt;
      (Dictionary&lt;Expression&lt;Func&lt;TElement, TValue&gt;&gt;, IEnumerable&lt;TValue&gt;&gt; expressionSet)
  {
      List&lt;Expression&gt; newExpressions = new List&lt;Expression&gt;();
  
      foreach (var item in expressionSet)
      {
          if (null == item.Key) throw new ArgumentNullException("valueSelector");
          if (null == item.Value) throw new ArgumentNullException("values");
  
          ParameterExpression p = item.Key.Parameters.Single();
  
          if (!item.Value.Any()) return e =&gt; false;
  
          IEnumerable&lt;Expression&gt; expressions = item.Value
             .Select(value =&gt; (Expression)Expression.Equal(item.Key.Body, Expression.Constant(value, typeof(TValue))));
          Expression compExpression = expressions
              .Aggregate&lt;Expression&gt;((accumulate, equal) =&gt; Expression.OrElse(accumulate, equal));
          newExpressions.Add(Expression.Lambda&lt;Func&lt;TElement, bool&gt;&gt;(compExpression, p));
      }
  
      Expression accExpression = newExpressions
          .Aggregate&lt;Expression&gt;((accumulate, equal) =&gt; Expression.OrElse(accumulate, equal));
  
      return Expression.Lambda&lt;Func&lt;TElement, bool&gt;&gt;(accExpression);
  }
  </code></pre>
  
  <p>But instead of doing the <code>Expression.Equal</code> somehow doing a <code>String.Contains</code>.</p>
  
  <p>Any help welcomed. By the way the code above is not tested.</p>