/// <summary>
        /// Registers the OpenIddict entity sets in the Entity Framework Core
        /// context using the specified entities and the specified key type.
        /// </summary>
        /// <param name="builder">The builder used to configure the Entity Framework context.</param>
        /// <returns>The Entity Framework context builder.</returns>
        public static DbContextOptionsBuilder UseOpenIddict <TApplication, TAuthorization, TScope, TToken, TKey>([NotNull] this DbContextOptionsBuilder builder)
            where TApplication : OpenIddictApplication <TKey, TAuthorization, TToken>
            where TAuthorization : OpenIddictAuthorization <TKey, TApplication, TToken>
            where TScope : OpenIddictScope <TKey>
            where TToken : OpenIddictToken <TKey, TApplication, TAuthorization>
            where TKey : IEquatable <TKey>
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            return(builder.ReplaceService <IModelCustomizer, OpenIddictEntityFrameworkCoreCustomizer <
                                               TApplication, TAuthorization, TScope, TToken, TKey> >());
        }
コード例 #2
0
        public static DbContextOptionsBuilder EnableTemporalTableQueries([NotNull] this DbContextOptionsBuilder optionsBuilder)
        {
            // If service provision is NOT being performed internally, we cannot replace services.
            var coreOptions = optionsBuilder.Options.GetExtension <CoreOptionsExtension>();

            if (coreOptions.InternalServiceProvider == null)
            {
                return(optionsBuilder
                       // replace the service responsible for generating SQL strings
                       .ReplaceService <IQuerySqlGeneratorFactory, TemporalQuerySqlGeneratorFactory>()
                       // replace the service responsible for traversing the Linq AST (a.k.a Query Methods)
                       .ReplaceService <IQueryableMethodTranslatingExpressionVisitorFactory, TemporalQueryableMethodTranslatingExpressionVisitorFactory>()
                       // replace the service responsible for providing instances of SqlExpressions
                       .ReplaceService <ISqlExpressionFactory, TemporalSqlExpressionFactory>());
            }
            else
            {
                return(optionsBuilder);
            }
        }
コード例 #3
0
        public static DbContextOptionsBuilder UseIdentityServer(this DbContextOptionsBuilder optionsBuilder, Action <AtaogeDbContextOptionsExtension> options)
        {
            var infrastructure = ((IDbContextOptionsBuilderInfrastructure)optionsBuilder);
            var contextOptions = optionsBuilder.Options;

            var ataogeOptionsExtension = optionsBuilder.Options.FindExtension <AtaogeDbContextOptionsExtension>() ?? new AtaogeDbContextOptionsExtension();


            infrastructure.AddOrUpdateExtension(ataogeOptionsExtension);


            if (options != null)
            {
                options(ataogeOptionsExtension);
            }

            if (ataogeOptionsExtension.UseInnerModel)
            {
                optionsBuilder.ReplaceService <IModelCustomizer, IdentityServerModelCustomizer>();
            }
            return(optionsBuilder);
        }
コード例 #4
0
 public static DbContextOptionsBuilder EnableUserDefinedTypesNotificationsSupport(this DbContextOptionsBuilder builder)
 {
     return(builder.ReplaceService <IInternalEntityEntrySubscriber, EntityEntrySubscriber> ( ));
 }
コード例 #5
0
 public static void UseBatchEF_MySQLPomelo(this DbContextOptionsBuilder optBuilder)
 {
     optBuilder.ReplaceService <IQuerySqlGeneratorFactory, ZackQuerySqlGeneratorFactory_MySQLPomelo>();
 }
 /// <summary>
 /// 使用RivenFx的PostgreSQL SqlGeneration实现
 /// </summary>
 /// <param name="optionsBuilder"></param>
 /// <returns></returns>
 public static DbContextOptionsBuilder UseRivenPostgreSqlGeneration(this DbContextOptionsBuilder optionsBuilder)
 {
     return(optionsBuilder
            .ReplaceService <ISqlGenerationHelper, RivenPostgreSqlGenerationHelper>());
 }
コード例 #7
0
 public static DbContextOptionsBuilder UseCustomSqlServerQuerySqlGenerator(this DbContextOptionsBuilder optionsBuilder)
 {
     optionsBuilder.ReplaceService <IQuerySqlGeneratorFactory, CustomSqlServerQuerySqlGeneratorFactory>();
     return(optionsBuilder);
 }
コード例 #8
0
 public static DbContextOptionsBuilder UseCustomExtensions(this DbContextOptionsBuilder optionsBuilder)
 => optionsBuilder
 .ReplaceService <INodeTypeProviderFactory, CustomNodeTypeProviderFactory>()
 .ReplaceService <IRelationalResultOperatorHandler, CustomRelationalResultOperatorHandler>();
コード例 #9
0
 public static DbContextOptionsBuilder UseRemoveForeignKeyService(this DbContextOptionsBuilder options)
 {
     options.ReplaceService <IMigrationsSqlGenerator, CustomMigrationsSqlGeneratore>();
     return(options);
 }
コード例 #10
0
 protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
 => optionsBuilder
 .ReplaceService <IDbContextTransactionManager, FakeTransactionManager>()
 .EnableServiceProviderCaching(false)
 .UseInMemoryDatabase(Guid.NewGuid().ToString());
コード例 #11
0
 public static DbContextOptionsBuilder UseStronglyTypedIdValueConverters(this DbContextOptionsBuilder options)
 {
     return(options
            .ReplaceService <IValueConverterSelector, CustomValueConverterSelector>());
 }
コード例 #12
0
 /// <summary>
 /// 使用 RivenFx 实现的 Oracle RelationalTypeMappingSource
 /// </summary>
 /// <param name="optionsBuilder"></param>
 /// <returns></returns>
 public static DbContextOptionsBuilder UseRivenOracleTypeMapping(this DbContextOptionsBuilder optionsBuilder)
 {
     return(optionsBuilder
            .ReplaceService <IRelationalTypeMappingSource, RivenOracleTypeMappingSource>()
            );
 }
コード例 #13
0
 /// <summary>
 /// 使用 RivenFx 实现的 Oracle RelationalCommandBuilderFactory
 /// </summary>
 /// <param name="optionsBuilder"></param>
 /// <returns></returns>
 public static DbContextOptionsBuilder UseRivenOracleRelationalCommandBuilderFactory(this DbContextOptionsBuilder optionsBuilder)
 {
     return(optionsBuilder
            .ReplaceService <IRelationalCommandBuilderFactory, RivenOracleRelationalCommandBuilderFactory>()
            );
 }
コード例 #14
0
 /// <summary>
 /// 使用 RivenFx 实现的 Oracle SqlGeneration ToUpper
 /// </summary>
 /// <param name="optionsBuilder"></param>
 /// <returns></returns>
 public static DbContextOptionsBuilder UseRivenOracleSqlGenerationToUpper(this DbContextOptionsBuilder optionsBuilder)
 {
     return(optionsBuilder
            .ReplaceService <ISqlGenerationHelper, RivenOracleSqlGenerationHelperToUpper>()
            );
 }
コード例 #15
0
 public static DbContextOptionsBuilder UseNpgsqlCaseInsensitive(this DbContextOptionsBuilder builder, string connectionString)
 {
     builder.UseNpgsql(connectionString);
     return(builder.ReplaceService <IQuerySqlGeneratorFactory, CaseInsensitiveSqlGeneratorFactory>());
 }