title: Lambda Expression With Contains Not Working
body: <p>I'm new to Lambda Expressions and I'm having some problems getting the output that I want.  More specifically, I'm having trouble with getting the LINQ contains part of the Lambda Expression correct.</p>
  
  <p>Here's what I have so far:</p>
  
  <pre><code>// The following line is what I want for my Final Result
  var distinctValues = db.Equipment.Where(m =&gt; m.Model != null &amp;&amp; m.Model.Contains(SearchTerm)).Select(m =&gt; m.Model).Distinct().ToList();
  
  var queryableData = db.Equipment.AsQueryable();
  
  var parameterExpression = Expression.Parameter(typeof(Equipment), Column);
  var constant = Expression.Constant(null);
  
  var property = Expression.Property(parameterExpression, Column);
  var expression1 = Expression.NotEqual(property, constant);
  var expression2 = Expression.Equal(property,constant);
  
  Expression callContains = Expression.Call(typeof(Queryable), "Contains", new[] { &lt;string&gt; } );
  
  var lambda1 = Expression.Lambda&lt;Func&lt;Equipment, bool&gt;&gt;(expression1, parameterExpression);
  var lambda2 = Expression.Lambda&lt;Func&lt;Equipment, string&gt;&gt;(property, parameterExpression);
  var lambda3 = Expression.Lambda&lt;Func&lt;Equipment, bool&gt;&gt;(callContains, parameterExpression);
  var compiledLambda1 = lambda1.Compile();
  var compiledLambda2 = lambda2.Compile();
  </code></pre>
  
  <p>I'm passing in any property and a search term and I want to generate the equivalent of the LINQ Query above as a Lambda Expression that starts with "var distinctValues".  I'm having trouble with the line that starts with "Expression callContains".  </p>
  
  <p>Any assistance is much appreciated.</p>
  
  <p>Thanks,</p>
  
  <p>Pete</p>