title: No method 'Contains' exists on type 'System.Data.Linq.DataQuery`1[System.Object]'
body: <p>I am trying to build contains expression.</p>
  
  <pre><code>private Expression&lt;Func&lt;T, bool&gt;&gt; Contains&lt;T&gt;(string property, IEnumerable&lt;dynamic&gt; values, T item)
  {
      ParameterExpression pe = Expression.Parameter(item.GetType(), "c");
      Expression columnNameProperty = Expression.Property(pe, property);
      var someValueContain = Expression.Constant(values, values.GetType());
      var convertExpression = Expression.Convert(columnNameProperty, typeof(Guid));
      Expression expression = Expression.Call(someValueContain, "Contains", new Type[] { }, convertExpression);
  
      return Expression.Lambda&lt;Func&lt;T, bool&gt;&gt;(expression, pe);
  }
  </code></pre>
  
  <p>at run time I got this exception.</p>
  
  <blockquote>
    <p>"No method 'Contains' exists on type
    'System.Data.Linq.DataQuery`1[System.Object]'."</p>
  </blockquote>
  
  <p>the soultion was to cast values parameter to list</p>
  
  <pre><code>private Expression&lt;Func&lt;T, bool&gt;&gt; Contains&lt;T&gt;(string property, IEnumerable&lt;dynamic&gt; values, T item)
  {
      ParameterExpression pe = Expression.Parameter(item.GetType(), "c");
      Expression columnNameProperty = Expression.Property(pe, property);
      Guidvalues = values.Cast&lt;Guid&gt;().ToList();
      var someValueContain = Expression.Constant(Guidvalues, Guidvalues.GetType());
      var convertExpression = Expression.Convert(columnNameProperty, typeof(Guid));
      Expression expression = Expression.Call(someValueContain, "Contains", new Type[] { }, convertExpression);
  
      return Expression.Lambda&lt;Func&lt;T, bool&gt;&gt;(expression, pe);
  }
  </code></pre>
  
  <p>the problem that the values list is more that 10000 so the performance was low and I got this exception </p>
  
  <blockquote>
    <p>"The incoming request has too many parameters. The server supports a
    maximum of 2100 parameters. Reduce the number of parameters and resend
    the request."</p>
  </blockquote>
  
  <p>I there any way to build dynamically lambda expression that generate like this query</p>
  
  <pre><code>select * from x where id in (select id from y)
  </code></pre>