This question already has an answer here:
- Select Right Generic Method with Reflection 11 answers
System.Linq.Queryable
has 2 Where
Methods that differ sligtly:
public static IQueryable<TSource> Where<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, int, bool>> predicate);
public static IQueryable<TSource> Where<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate);
I need to select the seconds one with the Expression<Func<TSource, bool>>
parameter.
I tried so far:
typeof(Queryable).GetTypeInfo()
.GetMethod(nameof(Queryable.Where), new [] { typeof(IQueryable<object>), typeof(Expression<Func<object,bool>>) })
// results in null
typeof(Queryable).GetTypeInfo()
.GetMethod(nameof(Queryable.Where), new [] { typeof(IQueryable<>), typeof(Expression<Func<,>>) })
// Error: Unexpected use of an unbound generic name
typeof(Queryable).GetTypeInfo()
.GetMethod(nameof(Queryable.Where), new [] { typeof(IQueryable<>), typeof(Expression<Func<,>>) })
// Exception: Ambiguous match found
What do I have to specify to get the second method without using GetMethods()
and relying on it being the second one.
Aucun commentaire:
Enregistrer un commentaire