title: How do I create an expression tree calling IEnumerable<TSource>.Any(...)?
body: <p>I am trying to create an expression tree that represents the following:</p>
  
  <pre><code>myObject.childObjectCollection.Any(i =&gt; i.Name == "name");
  </code></pre>
  
  <p>Shortened for clarity, I have the following:</p>
  
  <pre><code>//'myObject.childObjectCollection' is represented here by 'propertyExp'
  //'i =&gt; i.Name == "name"' is represented here by 'predicateExp'
  //but I am struggling with the Any() method reference - if I make the parent method
  //non-generic Expression.Call() fails but, as per below, if i use &lt;T&gt; the 
  //MethodInfo object is always null - I can't get a reference to it
  
  private static MethodCallExpression GetAnyExpression&lt;T&gt;(MemberExpression propertyExp, Expression predicateExp)
  {
      MethodInfo method = typeof(Enumerable).GetMethod("Any", new[]{ typeof(Func&lt;IEnumerable&lt;T&gt;, Boolean&gt;)});
      return Expression.Call(propertyExp, method, predicateExp);
  }
  </code></pre>
  
  <p>What am I doing wrong? Anyone have any suggestions?</p>