/// <summary> /// Adds default <see cref="WarningBehavior" /> for relational events. /// </summary> /// <param name="coreOptionsExtension">The core options extension.</param> /// <returns>The new core options extension.</returns> public static CoreOptionsExtension WithDefaultWarningConfiguration(CoreOptionsExtension coreOptionsExtension) => coreOptionsExtension.WithWarningsConfiguration( coreOptionsExtension.WarningsConfiguration .TryWithExplicit(RelationalEventId.AmbientTransactionWarning, WarningBehavior.Throw) .TryWithExplicit(RelationalEventId.IndexPropertiesBothMappedAndNotMappedToTable, WarningBehavior.Throw) .TryWithExplicit(RelationalEventId.IndexPropertiesMappedToNonOverlappingTables, WarningBehavior.Throw) .TryWithExplicit(RelationalEventId.ForeignKeyPropertiesMappedToUnrelatedTables, WarningBehavior.Throw));
/// <summary> /// 配置报警扩展 /// </summary> /// <param name="optionsBuilder"></param> private static void ConfigureWarnings(DbContextOptionsBuilder optionsBuilder) { CoreOptionsExtension coreOptionsExtension = optionsBuilder.Options.FindExtension <CoreOptionsExtension>() ?? new CoreOptionsExtension(); coreOptionsExtension = coreOptionsExtension.WithWarningsConfiguration(coreOptionsExtension.WarningsConfiguration.TryWithExplicit(RelationalEventId.AmbientTransactionWarning, WarningBehavior.Throw)); ((IDbContextOptionsBuilderInfrastructure)optionsBuilder).AddOrUpdateExtension(coreOptionsExtension); }
public TExtension FindExtension <TExtension>() where TExtension : class, IDbContextOptionsExtension { var coreOptionsExtension = new CoreOptionsExtension(); if (_serviceProvider != null) { coreOptionsExtension = coreOptionsExtension.WithApplicationServiceProvider(_serviceProvider); } return((TExtension)(object)coreOptionsExtension); }
protected override void OnConfiguringService(IServiceCollection services) { //services.AddSingleton<IStartupConfiguration>(sp => new StartupConfiguration(sp)); services.AddSingleton <INavigationManager, NavigationManager>(); CoreOptionsExtension coreOptionsExtension = GetOrCreateExtension <CoreOptionsExtension>(); if (coreOptionsExtension.UserIndentifier != null) { var keyType = TypeUtils.FindGenericTypeArguments(coreOptionsExtension.UserIndentifier, typeof(IUserIdentifier <>)); services.AddTransient(typeof(IUserNavigationManager <>).MakeGenericType(keyType), typeof(UserNavigationManager <>).MakeGenericType(keyType)); services.AddSingleton(typeof(ISafSession <>).MakeGenericType(keyType), typeof(ClaimsSafSession <>).MakeGenericType(keyType)); } services.TryAddSingleton <Infrastructure.INavigationConfiguration>(coreOptionsExtension.NavigationConfiguration); //添加后台队列 services.AddBackgroundQueue(); }
public ExtensionInfo(CoreOptionsExtension extension) : base(extension) { }