Ejemplo n.º 1
0
 /// <summary>
 /// Adds custom factory required for translation of custom methods like <see cref="RelationalQueryableExtensions.AsSubQuery{TEntity}"/>.
 /// </summary>
 /// <param name="builder">Options builder.</param>
 /// <param name="addCustomQueryableMethodTranslatingExpressionVisitorFactory">Indication whether to add a custom factory.</param>
 /// <returns>Provided <paramref name="builder"/>.</returns>
 public static SqlServerDbContextOptionsBuilder AddCustomQueryableMethodTranslatingExpressionVisitorFactory(
     this SqlServerDbContextOptionsBuilder builder,
     bool addCustomQueryableMethodTranslatingExpressionVisitorFactory = true)
 {
     builder.AddOrUpdateExtension(extension => extension.AddCustomQueryableMethodTranslatingExpressionVisitorFactory = addCustomQueryableMethodTranslatingExpressionVisitorFactory);
     return(builder);
 }
Ejemplo n.º 2
0
        public void ConfigureServices(IServiceCollection services)
        {
            ComponentsContainerHelper.RegisterDefaultServices(services);

            services.AddSeriLog(Configuration);

            services.AddControllers(options => { options.RespectBrowserAcceptHeader = true; });

            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(Configuration, "Content");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new ExposureContentDbContext(builder.Build());
                result.BeginTransaction();
                return(result);
            });

            services.AddSingleton <IUtcDateTimeProvider>(new StandardUtcDateTimeProvider());
            services.AddSingleton <IPublishingId, StandardPublishingIdFormatter>();

            services.AddScoped <HttpGetCdnManifestCommand, HttpGetCdnManifestCommand>();
            services.AddScoped <HttpGetCdnContentCommand <AppConfigContentEntity>, HttpGetCdnContentCommand <AppConfigContentEntity> >();
            services.AddScoped <HttpGetCdnContentCommand <ResourceBundleContentEntity>, HttpGetCdnContentCommand <ResourceBundleContentEntity> >();
            services.AddScoped <HttpGetCdnContentCommand <RiskCalculationContentEntity>, HttpGetCdnContentCommand <RiskCalculationContentEntity> >();
            services.AddScoped <HttpGetCdnContentCommand <ExposureKeySetContentEntity>, HttpGetCdnContentCommand <ExposureKeySetContentEntity> >();

            services.AddScoped <IReader <ManifestEntity>, SafeBinaryContentDbReader <ManifestEntity> >();
            services.AddScoped <IReader <AppConfigContentEntity>, SafeBinaryContentDbReader <AppConfigContentEntity> >();
            services.AddScoped <IReader <ResourceBundleContentEntity>, SafeBinaryContentDbReader <ResourceBundleContentEntity> >();
            services.AddScoped <IReader <RiskCalculationContentEntity>, SafeBinaryContentDbReader <RiskCalculationContentEntity> >();
            services.AddScoped <IReader <ExposureKeySetContentEntity>, SafeBinaryContentDbReader <ExposureKeySetContentEntity> >();
        }
Ejemplo n.º 3
0
        public CreateWorkflowDatabase(IConfiguration configuration)
        {
            var config  = new StandardEfDbConfig(configuration, "Workflow");
            var builder = new SqlServerDbContextOptionsBuilder(config);

            _Provider = new WorkflowDbContext(builder.Build());
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Adds support for "RowNumber".
 /// </summary>
 /// <param name="builder">Options builder.</param>
 /// <param name="addRowNumberSupport">Indication whether to enable or disable the feature.</param>
 /// <returns>Provided <paramref name="builder"/>.</returns>
 public static SqlServerDbContextOptionsBuilder AddRowNumberSupport(
     this SqlServerDbContextOptionsBuilder builder,
     bool addRowNumberSupport = true)
 {
     builder.AddOrUpdateExtension(extension => extension.AddRowNumberSupport = addRowNumberSupport);
     return(builder);
 }
        /// <inheritdoc />
        protected override void ConfigureSqlServer(SqlServerDbContextOptionsBuilder builder)
        {
            base.ConfigureSqlServer(builder);

            builder.AddRowNumberSupport()
            .AddTempTableSupport();
        }
Ejemplo n.º 6
0
        public static void ConfigureServices(IServiceCollection services)
        {
            services.AddSeriLog(Configuration);
            services.AddSingleton(Configuration);
            services.AddTransient <App>();

            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(Configuration, "Content");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new ExposureContentDbContext(builder.Build());
                return(result);
            });

            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(Configuration, "Workflow");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new WorkflowDbContext(builder.Build());
                return(result);
            });

            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(Configuration, "Icc");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new IccBackendContentDbContext(builder.Build());
                return(result);
            });
        }
        public static SqlServerDbContextOptionsBuilder AddCustomSchemaExtension(this SqlServerDbContextOptionsBuilder sqlServerDbContextOptionsBuilder, IServiceCollection services)
        {
            var infrastructure = sqlServerDbContextOptionsBuilder as IRelationalDbContextOptionsBuilderInfrastructure;

            infrastructure.AddCustomSchemaExtension(services);
            return(sqlServerDbContextOptionsBuilder);
        }
Ejemplo n.º 8
0
        public static DataProtectionKeysDbContext DataProtectionKeys(IServiceProvider x)
        {
            var config  = new StandardEfDbConfig(x.GetRequiredService <IConfiguration>(), DatabaseConnectionStringNames.DataProtectionKeys);
            var builder = new SqlServerDbContextOptionsBuilder(config, x.GetRequiredService <ILoggerFactory>());

            return(new DataProtectionKeysDbContext(builder.Build()));
        }
Ejemplo n.º 9
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();

            services.AddSeriLog(Configuration);

            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(Configuration, "WorkFlow");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new WorkflowDbContext(builder.Build());
                return(result);
            });

            services.AddSingleton <IUtcDateTimeProvider, StandardUtcDateTimeProvider>();

            services.AddScoped <HttpPostKeysLastAuthorise, HttpPostKeysLastAuthorise>();
            services.AddScoped <IKeysLastSignatureValidator, KeysLastSignatureValidator>();
            services.AddScoped <IKeysLastAuthorisationWriter, KeysLastAuthorisationWriter>();

            services.AddSwaggerGen(o =>
            {
                o.SwaggerDoc("v1", new OpenApiInfo {
                    Title = Title, Version = "v1"
                });
            });
        }
Ejemplo n.º 10
0
        public CreateIccDatabase(IConfiguration configuration)
        {
            var config  = new StandardEfDbConfig(configuration, "Icc");
            var builder = new SqlServerDbContextOptionsBuilder(config);

            _Provider = new IccBackendContentDbContext(builder.Build());
        }
Ejemplo n.º 11
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddScoped(x => DbContextStartup.Workflow(x, false));
            services.AddScoped(x => DbContextStartup.Content(x, false));
            services.AddScoped(x => DbContextStartup.Publishing(x, false));

            services.AddTransient <ContentValidator>();
            services.AddTransient <ContentInsertDbCommand>();

            services.NlSignerStartup(_Configuration.UseCertificatesFromResources());
            services.GaSignerStartup(_Configuration.UseCertificatesFromResources());

            // Database Scoping
            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(_Configuration, "WorkFlow");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new WorkflowDbContext(builder.Build());
                result.BeginTransaction();
                return(result);
            });

            services.AddScoped <IUtcDateTimeProvider, StandardUtcDateTimeProvider>();
            services.AddTransient <IPublishingIdService, Sha256HexPublishingIdService>();
            services.AddTransient <ZippedSignedContentFormatter>();

            services.AddControllersWithViews();
        }
Ejemplo n.º 12
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();
            services.AddSeriLog(Configuration);

            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(Configuration, "WorkFlow");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new WorkflowDbContext(builder.Build());
                return(result);
            });

            services.AddSingleton <IUtcDateTimeProvider, StandardUtcDateTimeProvider>();
            services.AddSingleton <IGeanTekListValidationConfig, StandardGeanCommonWorkflowConfig>();
            services.AddSingleton <ITemporaryExposureKeyValidator, TemporaryExposureKeyValidator>();
            services.AddSingleton <ITemporaryExposureKeyValidatorConfig, TemporaryExposureKeyValidatorConfig>();

            services.AddScoped <HttpPostKeysLastReleaseTeksCommand, HttpPostKeysLastReleaseTeksCommand>();

            services.AddScoped <IKeysLastReleaseTeksValidator, KeysLastReleaseTeksValidator>();
            services.AddScoped <IKeysLastSignatureValidator, FakeKeysLastSignatureValidator>();

            services.AddScoped <HttpPostKeysLastRegisterSecret, HttpPostKeysLastRegisterSecret>();
            services.AddScoped <IKeysLastSecretWriter, KeysLastSecretWriter>();
            services.AddScoped <IKeysLastSecretConfig, StandardKeysLastSecretConfig>();
            services.AddScoped <IKeysLastTekWriter, FakeKeysLastTekWriter>();

            services.AddSwaggerGen(o =>
            {
                o.SwaggerDoc("v1", new OpenApiInfo {
                    Title = Title, Version = "v1"
                });
            });
        }
        public static SqlServerDbContextOptionsBuilder AddCustomSchemaModelSupport(this SqlServerDbContextOptionsBuilder sqlServerDbContextOptionsBuilder, DbContextOptionsBuilder dbContextOptionsBuilder, IServiceCollection services)
        {
            services.AddTransient <CustomSchemaOptionsExtension>();
            dbContextOptionsBuilder.ReplaceService <IModelCacheKeyFactory, CustomSchemaModelCacheKeyFactory>();
            sqlServerDbContextOptionsBuilder.AddCustomSchemaExtension(services);

            return(sqlServerDbContextOptionsBuilder);
        }
Ejemplo n.º 14
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers(options => { options.RespectBrowserAcceptHeader = true; });

            services.AddControllers();

            // Database Scoping
            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(Configuration, "Icc");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new IccBackendContentDbContext(builder.Build());
                result.BeginTransaction();
                return(result);
            });
            services.AddScoped <IEfDbConfig>(x => new StandardEfDbConfig(Configuration, "Icc"));
            services.AddScoped <ProvisionDatabasesCommandIcc, ProvisionDatabasesCommandIcc>();
            services.AddScoped <IUtcDateTimeProvider, StandardUtcDateTimeProvider>();
            services.AddScoped <IRandomNumberGenerator, RandomNumberGenerator>();
            services.AddScoped <IBasicAuthenticationConfig, BasicAuthenticationConfig>();
            services.AddScoped <IIccService, IccService>();
            services.AddScoped <AppBackendService, AppBackendService>();
            services.AddAuthentication("IccAuthentication")
            .AddScheme <AuthenticationSchemeOptions, IccAuthenticationHandler>("IccAuthentication", null);

            services.AddCors();

            services.AddSwaggerGen(o =>
            {
                o.SwaggerDoc("v1", new OpenApiInfo
                {
                    Title       = "Dutch Exposure Notification ICC API (inc. dev support)",
                    Version     = "v1",
                    Description = "This specification describes the interface between the Dutch exposure notification app backend, ICC Webportal and the ICC backend service.",
                    Contact     = new OpenApiContact
                    {
                        Name = "Ministerie van Volksgezondheid Welzijn en Sport backend repository", //TODO looks wrong?
                        Url  = new Uri("https://github.com/minvws/nl-covid19-notification-app-backend"),
                    },
                    License = new OpenApiLicense
                    {
                        Name = "European Union Public License v. 1.2",
                        //TODO this should be https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
                        Url = new Uri("https://github.com/minvws/nl-covid19-notification-app-backend/blob/master/LICENSE.txt")
                    },
                });
                o.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, "NL.Rijksoverheid.ExposureNotification.BackEnd.Components.xml"));
                o.AddSecurityDefinition("Icc", new OpenApiSecurityScheme
                {
                    Description = "Icc Code Authentication",
                    Name        = "Authorization",
                    In          = ParameterLocation.Header,
                    Type        = SecuritySchemeType.ApiKey,
                    Scheme      = "IccAuthentication"
                });
                o.OperationFilter <SecurityRequirementsOperationFilter>();
            });
        }
 private void SqlServerOptionsAction(SqlServerDbContextOptionsBuilder optionsBuilder)
 => optionsBuilder
 .ExecutionStrategy(
     dependencies => new SqlServerRetryingExecutionStrategy(
         dependencies: dependencies,
         maxRetryCount: _itauCoinExchageSqlServerOptions.MaxRetryCount,
         maxRetryDelay: TimeSpan.FromSeconds(_itauCoinExchageSqlServerOptions.MaxRetryDelayInSeconds),
         errorNumbersToAdd: _itauCoinExchageSqlServerOptions.ErrorNumbersToAdd))
 .MigrationsAssembly(assemblyName: typeof(ItauCoinExchangeDbContext).Assembly.GetName().Name);
Ejemplo n.º 16
0
 private void SqlServerOptionsAction(SqlServerDbContextOptionsBuilder optionsBuilder)
 => optionsBuilder
 .ExecutionStrategy(
     dependencies => new SqlServerRetryingExecutionStrategy(
         dependencies: dependencies,
         maxRetryCount: _options.MaxRetryCount,
         maxRetryDelay: _options.MaxRetryDelay,
         errorNumbersToAdd: _options.ErrorNumbersToAdd))
 .MigrationsAssembly(assemblyName: typeof(StoreDbContext).Assembly.GetName().Name);
Ejemplo n.º 17
0
        public CreateContentDatabase(IConfiguration configuration, IUtcDateTimeProvider dateTimeProvider, IContentSigner signer)
        {
            var config  = new StandardEfDbConfig(configuration, "Content");
            var builder = new SqlServerDbContextOptionsBuilder(config);

            _DbContextProvider = new ExposureContentDbContext(builder.Build());
            _DateTimeProvider  = dateTimeProvider;
            _Formatter         = new StandardContentEntityFormatter(new ZippedSignedContentFormatter(signer), new StandardPublishingIdFormatter());
        }
Ejemplo n.º 18
0
        private static SqlServerDbContextOptionsBuilder AddOrUpdateExtensions([NotNull] this SqlServerDbContextOptionsBuilder sqlServerOptionsBuilder,
                                                                              [NotNull] Action <SqlServerDbContextOptionsExtension> callback)
        {
            var infrastructure = (IRelationalDbContextOptionsBuilderInfrastructure)sqlServerOptionsBuilder;

            infrastructure.OptionsBuilder.AddOrUpdateExtension(callback);

            return(sqlServerOptionsBuilder);
        }
Ejemplo n.º 19
0
        public WorkflowDatabaseCreateCommand(IConfiguration configuration, ITekValidatorConfig tekValidatorConfig, ILabConfirmationIdService labConfirmationIdService, IWorkflowConfig workflowConfig)
        {
            _TekValidatorConfig       = tekValidatorConfig ?? throw new ArgumentNullException(nameof(tekValidatorConfig));
            _LabConfirmationIdService = labConfirmationIdService ?? throw new ArgumentNullException(nameof(labConfirmationIdService));
            _WorkflowConfig           = workflowConfig ?? throw new ArgumentNullException(nameof(workflowConfig));
            var config  = new StandardEfDbConfig(configuration, "Workflow");
            var builder = new SqlServerDbContextOptionsBuilder(config);

            _Provider = new WorkflowDbContext(builder.Build());
        }
        /// <summary>
        /// Configures SQL Server options.
        /// </summary>
        /// <param name="builder">A builder for configuration of the options.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="builder"/> is null.</exception>
        protected virtual void ConfigureSqlServer([NotNull] SqlServerDbContextOptionsBuilder builder)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            builder.MigrationsHistoryTable(_HISTORY_TABLE_NAME, Schema)
            .UseThinktectureSqlServerMigrationsSqlGenerator();
        }
Ejemplo n.º 21
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            ComponentsContainerHelper.RegisterDefaultServices(services);

            services.AddBasicAuthentication();
            services.AddSeriLog(Configuration);
            services.AddControllers();
            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(Configuration, "Content");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new ExposureContentDbContext(builder.Build());
                result.BeginTransaction();
                return(result);
            });

            services.AddScoped <HttpPostContentReciever <ManifestEntity>, HttpPostContentReciever <ManifestEntity> >();
            services.AddScoped <HttpPostContentReciever <AppConfigContentEntity>, HttpPostContentReciever <AppConfigContentEntity> >();
            services.AddScoped <HttpPostContentReciever <ResourceBundleContentEntity>, HttpPostContentReciever <ResourceBundleContentEntity> >();
            services.AddScoped <HttpPostContentReciever <RiskCalculationContentEntity>, HttpPostContentReciever <RiskCalculationContentEntity> >();
            services.AddScoped <HttpPostContentReciever <ExposureKeySetContentEntity>, HttpPostContentReciever <ExposureKeySetContentEntity> >();

            services.AddSwaggerGen(o =>
            {
                o.SwaggerDoc("v1", new OpenApiInfo
                {
                    Title   = "Azure CDN Data Receiver API",
                    Version = "v1",
                });

                o.AddSecurityDefinition("basic", new OpenApiSecurityScheme
                {
                    Name        = "Authorization",
                    Type        = SecuritySchemeType.Http,
                    Scheme      = "basic",
                    In          = ParameterLocation.Header,
                    Description = "Basic Authorization header using the Bearer scheme."
                });

                o.AddSecurityRequirement(new OpenApiSecurityRequirement
                {
                    {
                        new OpenApiSecurityScheme
                        {
                            Reference = new OpenApiReference
                            {
                                Type = ReferenceType.SecurityScheme,
                                Id   = "basic"
                            }
                        },
                        new string[] {}
                    }
                });
            });
        }
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            ComponentsContainerHelper.RegisterDefaultServices(services);

            services.AddControllers();

            services.AddSeriLog(Configuration);
            services.AddBasicAuthentication();

            services.AddScoped(x =>
            {
                var config  = new StandardEfDbConfig(Configuration, "WorkFlow");
                var builder = new SqlServerDbContextOptionsBuilder(config);
                var result  = new WorkflowDbContext(builder.Build());
                result.Database.BeginTransaction();
                return(result);
            });

            services.AddSingleton <IUtcDateTimeProvider, StandardUtcDateTimeProvider>();

            services.AddScoped <HttpPostAuthorise, HttpPostAuthorise>();
            services.AddScoped <ISignatureValidator, SignatureValidator>();
            services.AddScoped <IAuthorisationWriter, AuthorisationWriter>();

            services.AddSwaggerGen(o =>
            {
                o.SwaggerDoc("v1", new OpenApiInfo {
                    Title = Title, Version = "v1"
                });

                o.AddSecurityDefinition("basic", new OpenApiSecurityScheme
                {
                    Name        = "Authorization",
                    Type        = SecuritySchemeType.Http,
                    Scheme      = "basic",
                    In          = ParameterLocation.Header,
                    Description = "Basic Authorization header using the Bearer scheme."
                });

                o.AddSecurityRequirement(new OpenApiSecurityRequirement
                {
                    {
                        new OpenApiSecurityScheme
                        {
                            Reference = new OpenApiReference
                            {
                                Type = ReferenceType.SecurityScheme,
                                Id   = "basic"
                            }
                        },
                        new string[] {}
                    }
                });
            });
        }
Ejemplo n.º 23
0
 public static void GetSqlServerOptions(SqlServerDbContextOptionsBuilder builder)
 {
     builder
     .MigrationsAssembly("StarCitizen.Gimp.Web")
     .EnableRetryOnFailure
     (
         5,
         TimeSpan.FromSeconds(30d),
         null
     );
 }
Ejemplo n.º 24
0
 private static void Configure(IServiceCollection services, IConfigurationRoot configuration)
 {
     services.AddScoped(x =>
     {
         var config  = new StandardEfDbConfig(configuration, "Workflow");
         var builder = new SqlServerDbContextOptionsBuilder(config);
         var result  = new WorkflowDbContext(builder.Build());
         return(result);
     });
     services.AddTransient <GenerateTeksCommand>();
     services.AddSingleton <IConfiguration>(configuration);
 }
Ejemplo n.º 25
0
        public static StatsDbContext Stats(IServiceProvider x, bool beginTrans = true)
        {
            var config  = new StandardEfDbConfig(x.GetRequiredService <IConfiguration>(), DatabaseConnectionStringNames.Stats);
            var builder = new SqlServerDbContextOptionsBuilder(config, x.GetRequiredService <ILoggerFactory>());
            var result  = new StatsDbContext(builder.Build());

            if (beginTrans)
            {
                result.BeginTransaction();
            }
            return(result);
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Adds SqlServer sequence providers and therefore enables operations on sequences.
        /// </summary>
        /// <param name="sqlServerOptionsBuilder"></param>
        /// <returns></returns>
        public static SqlServerDbContextOptionsBuilder UseSequences(this SqlServerDbContextOptionsBuilder sqlServerOptionsBuilder)
        {
            var infra   = (IRelationalDbContextOptionsBuilderInfrastructure)sqlServerOptionsBuilder;
            var builder = (IDbContextOptionsBuilderInfrastructure)infra.OptionsBuilder;

            var extension = infra.OptionsBuilder.Options.FindExtension <SqlServerDbContextOptionsExtension>() ??
                            new SqlServerDbContextOptionsExtension();

            builder.AddOrUpdateExtension(extension);

            return(sqlServerOptionsBuilder);
        }
        public IccDatabaseCreateCommand(IConfiguration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            var config  = new StandardEfDbConfig(configuration, "Icc");
            var builder = new SqlServerDbContextOptionsBuilder(config);

            _Provider = new IccBackendContentDbContext(builder.Build());
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Enable NodaTime mappings.
        /// </summary>
        /// <param name="optionsBuilder">The build being used to configure SQL Server.</param>
        /// <returns>The options builder so that further configuration can be chained.</returns>
        public static SqlServerDbContextOptionsBuilder UseNodaTime(
            this SqlServerDbContextOptionsBuilder optionsBuilder)
        {
            var coreOptionsBuilder = ((IRelationalDbContextOptionsBuilderInfrastructure)optionsBuilder).OptionsBuilder;

            var extension = coreOptionsBuilder.Options.FindExtension <NodaTimeOptionsExtension>()
                            ?? new NodaTimeOptionsExtension();

            ((IDbContextOptionsBuilderInfrastructure)coreOptionsBuilder).AddOrUpdateExtension(extension);

            return(optionsBuilder);
        }
Ejemplo n.º 29
0
        /// <inheritdoc />
        protected override void ConfigureSqlServer(SqlServerDbContextOptionsBuilder builder)
        {
            base.ConfigureSqlServer(builder);

            builder.AddTempTableSupport()
            .AddRowNumberSupport();

            if (IsTenantDatabaseSupportEnabled)
            {
                builder.AddTenantDatabaseSupport <TestTenantDatabaseProviderFactory>();
            }
        }
Ejemplo n.º 30
0
 /// <summary>
 /// Adds 'tenant database support'.
 /// </summary>
 /// <param name="builder">Options builder.</param>
 /// <param name="addTenantSupport">Indication whether to enable or disable the feature.</param>
 /// <param name="databaseProviderLifetime">The lifetime of the provided <typeparamref name="TTenantDatabaseProviderFactory"/>.</param>
 /// <returns>Provided <paramref name="builder"/>.</returns>
 public static SqlServerDbContextOptionsBuilder AddTenantDatabaseSupport <TTenantDatabaseProviderFactory>(
     this SqlServerDbContextOptionsBuilder builder,
     bool addTenantSupport = true,
     ServiceLifetime databaseProviderLifetime = ServiceLifetime.Singleton)
     where TTenantDatabaseProviderFactory : ITenantDatabaseProviderFactory
 {
     builder.AddOrUpdateExtension(extension =>
     {
         extension.AddTenantDatabaseSupport = addTenantSupport;
         extension.Add(ServiceDescriptor.Describe(typeof(ITenantDatabaseProviderFactory), typeof(TTenantDatabaseProviderFactory), databaseProviderLifetime));
     });
     return(builder);
 }
 protected override void ConfigureOptions(SqlServerDbContextOptionsBuilder sqlServerDbContextOptionsBuilder)
     => sqlServerDbContextOptionsBuilder.DisableQueryClientEvaluation();
 protected override void ConfigureOptions(SqlServerDbContextOptionsBuilder sqlServerDbContextOptionsBuilder)
     => sqlServerDbContextOptionsBuilder.UseRowNumberForPaging();
 protected virtual void ConfigureOptions(SqlServerDbContextOptionsBuilder sqlServerDbContextOptionsBuilder)
 {
 }