获取IncIn方法的MethodInfo

时间:2016-07-06 16:38:08

标签: c# entity-framework entity-framework-core

我使用以下命令获取OrderBy方法:

MethodInfo orderBy = typeof(Queryable)
  .GetMethods().First(x => x.Name == "OrderBy" && x.GetParameters()
  .Select(y => y.ParameterType.GetGenericTypeDefinition())
  .SequenceEqual(new[] { typeof(IQueryable<>), typeof(Expression<>) }));

但是如何对Include方法做同样的事情呢?我在Queryable中找不到它......

1 个答案:

答案 0 :(得分:1)

Include不在Queryable类中,而是在Entity Framework的 EntityFrameworkQueryableExtensions 类中

var type = typeof(Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions);