public static class DbContextExtension
{
public static IQueryable Query(this DbContext context, Type entityType)
{
var SetMethod = typeof(DbContext).GetMethod(nameof(DbContext.Set));
return (IQueryable)SetMethod.MakeGenericMethod(entityType).Invoke(context, null);
}
}
原文:https://www.cnblogs.com/saving/p/11334677.html