/// <summary> /// 启用Aop /// </summary> /// <param name="services">服务集合</param> /// <param name="configAction">Aop配置</param> public static void EnableAop(this IServiceCollection services, Action <IAspectConfiguration> configAction = null) { services.ConfigureDynamicProxy(config => { config.EnableParameterAspect(); config.NonAspectPredicates.Add(t => Reflections.GetTopBaseType(t.DeclaringType).SafeString() == "Microsoft.EntityFrameworkCore.DbContext"); configAction?.Invoke(config); }); services.EnableAspectScoped(); }