I have the following two Entity Framework's Include methods:
public static IIncludableQueryable<TEntity, TProperty> Include<TEntity, TProperty>(
[NotNullAttribute] this IQueryable<TEntity> source,
[NotNullAttribute] Expression<Func<TEntity, TProperty>> navigationPropertyPath)
where TEntity : class;
public static IQueryable<TEntity> Include<TEntity>(
[NotNullAttribute] this IQueryable<TEntity> source,
[NotNullAttribute][NotParameterized] string navigationPropertyPath)
where TEntity : class;
I need to get the MethodInfo for both methods. For the first one I used:
MethodInfo include1 = typeof(EntityFrameworkQueryableExtensions)
.GetMethods().First(x => x.Name == "Include" && x.GetParameters()
.Select(y => y.ParameterType.GetGenericTypeDefinition())
.SequenceEqual(new[] { typeof(IQueryable<>), typeof(Expression<>) }));
This works but when I try to get the second one using the following:
MethodInfo include2 = typeof(EntityFrameworkQueryableExtensions)
.GetMethods().First(x => x.Name == "Include" && x.GetParameters()
.Select(y => y.ParameterType.GetGenericTypeDefinition())
.SequenceEqual(new[] { typeof(IQueryable<>), typeof(String) }));
I get the error:
This operation is only valid on generic types
What am I missing?
Aucun commentaire:
Enregistrer un commentaire