I'm trying to build an Expression that makes a call to LINQ's Any() method, and I can't seem to find the right arguments to pass to Type.GetMethod().
From the docs, it looks like Any() is implemented as a member of the Enumerable class, and that seems to work, because this shows to methods named "Any":
var enumerableType = typeof (Enumerable);
var foo = enumerableType.GetMethods().Where(m => m.Name == "Any").ToList();
And when I as for the method named "Any", I get an AmbiguousMatchException.
There are two Any() methods, in Enumerable, one takes one parameter an IEnumerable, and the other takes an IEnumerable and a Func. I want the second, and theoretically, all I need to do is to pass an array containing the two types:
var bar = enumerableType.GetMethod("Any", new[] { typeof(IEnumerable<>), typeof(Func<,>) });
But this is always returning null.
What am I doing wrong?