public static DbContextOptionsBuilder UseDm( [NotNull] this AbpDbContextConfigurationContext context, [CanBeNull] Action <DmDbContextOptionsBuilder> dmOptionsAction = null) { if (context.ExistingConnection != null) { return(context.DbContextOptions.UseDm(context.ExistingConnection, optionsBuilder => { optionsBuilder.UseQuerySplittingBehavior(QuerySplittingBehavior.SplitQuery); dmOptionsAction?.Invoke(optionsBuilder); }) //.UseInternalServiceProvider(new ServiceCollection().AddEntityFrameworkDm().BuildServiceProvider()) ); } else { return(context.DbContextOptions.UseDm(context.ConnectionString, optionsBuilder => { optionsBuilder.UseQuerySplittingBehavior(QuerySplittingBehavior.SplitQuery); dmOptionsAction?.Invoke(optionsBuilder); }) //.UseInternalServiceProvider(new ServiceCollection().AddEntityFrameworkDm().BuildServiceProvider()) ); } }
public static DbContextOptionsBuilder UsePostgreSql( [NotNull] this AbpDbContextConfigurationContext context, [CanBeNull] Action <NpgsqlDbContextOptionsBuilder> postgreSqlOptionsAction = null) { if (context.ExistingConnection != null) { return(context.DbContextOptions.UseNpgsql(context.ExistingConnection, postgreSqlOptionsAction)); } else { return(context.DbContextOptions.UseNpgsql(context.ConnectionString, postgreSqlOptionsAction)); } }
public static DbContextOptionsBuilder UseSqlite( [NotNull] this AbpDbContextConfigurationContext context, [CanBeNull] Action <SqliteDbContextOptionsBuilder> sqliteOptionsAction = null) { if (context.ExistingConnection != null) { return(context.DbContextOptions.UseSqlite(context.ExistingConnection, sqliteOptionsAction)); } else { return(context.DbContextOptions.UseSqlite(context.ConnectionString, sqliteOptionsAction)); } }
public static DbContextOptionsBuilder UseMySQL( [NotNull] this AbpDbContextConfigurationContext context, [CanBeNull] Action <MySqlDbContextOptionsBuilder> mySQLOptionsAction = null) { if (context.ExistingConnection != null) { return(context.DbContextOptions.UseMySql(context.ExistingConnection, mySQLOptionsAction)); } else { return(context.DbContextOptions.UseMySql(context.ConnectionString, mySQLOptionsAction)); } }
public static DbContextOptionsBuilder UseFirebird( [NotNull] this AbpDbContextConfigurationContext context, [CanBeNull] Action <FbDbContextOptionsBuilder> fbOptionsAction = null) { if (context.ExistingConnection != null) { return(context.DbContextOptions.UseFirebird(context.ExistingConnection, fbOptionsAction)); } else { return(context.DbContextOptions.UseFirebird(context.ConnectionString, fbOptionsAction)); } }
public static DbContextOptionsBuilder UseOracle( [NotNull] this AbpDbContextConfigurationContext context, [CanBeNull] Action <OracleDbContextOptionsBuilder> oracleOptionsAction = null, bool useExistingConnectionIfAvailable = false) { if (useExistingConnectionIfAvailable && context.ExistingConnection != null) { return(context.DbContextOptions.UseOracle(context.ExistingConnection, oracleOptionsAction)); } else { return(context.DbContextOptions.UseOracle(context.ConnectionString, oracleOptionsAction)); } }
public static DbContextOptions <TDbContext> Create <TDbContext>(IServiceProvider serviceProvider) where TDbContext : AbpDbContext <TDbContext> { var creationContext = GetCreationContext <TDbContext>(serviceProvider); var context = new AbpDbContextConfigurationContext <TDbContext>( creationContext.ConnectionString, serviceProvider, creationContext.ConnectionStringName, creationContext.ExistingConnection ); var options = GetDbContextOptions <TDbContext>(serviceProvider); PreConfigure(options, context); Configure(options, context); return(context.DbContextOptions.Options); }
private static void PreConfigure <TDbContext>( AbpDbContextOptions options, AbpDbContextConfigurationContext <TDbContext> context) where TDbContext : AbpDbContext <TDbContext> { foreach (var defaultPreConfigureAction in options.DefaultPreConfigureActions) { defaultPreConfigureAction.Invoke(context); } var preConfigureActions = options.PreConfigureActions.GetOrDefault(typeof(TDbContext)); if (!preConfigureActions.IsNullOrEmpty()) { foreach (var preConfigureAction in preConfigureActions) { ((Action <AbpDbContextConfigurationContext <TDbContext> >)preConfigureAction).Invoke(context); } } }
public static DbContextOptionsBuilder UseSqlite( [NotNull] this AbpDbContextConfigurationContext context, [CanBeNull] Action <SqliteDbContextOptionsBuilder> sqliteOptionsAction = null) { if (context.ExistingConnection != null) { return(context.DbContextOptions.UseSqlite(context.ExistingConnection, optionsBuilder => { optionsBuilder.UseQuerySplittingBehavior(QuerySplittingBehavior.SplitQuery); sqliteOptionsAction?.Invoke(optionsBuilder); })); } else { return(context.DbContextOptions.UseSqlite(context.ConnectionString, optionsBuilder => { optionsBuilder.UseQuerySplittingBehavior(QuerySplittingBehavior.SplitQuery); sqliteOptionsAction?.Invoke(optionsBuilder); })); } }
private static void Configure <TDbContext>( AbpDbContextOptions options, AbpDbContextConfigurationContext <TDbContext> context) where TDbContext : AbpDbContext <TDbContext> { var configureAction = options.ConfigureActions.GetOrDefault(typeof(TDbContext)); if (configureAction != null) { ((Action <AbpDbContextConfigurationContext <TDbContext> >)configureAction).Invoke(context); } else if (options.DefaultConfigureAction != null) { options.DefaultConfigureAction.Invoke(context); } else { throw new AbpException( $"No configuration found for {typeof(DbContext).AssemblyQualifiedName}! Use services.Configure<AbpDbContextOptions>(...) to configure it."); } }
public static DbContextOptionsBuilder UseOracle( [NotNull] this AbpDbContextConfigurationContext context, [CanBeNull] Action <OracleDbContextOptionsBuilder> oracleOptionsAction = null, bool useExistingConnectionIfAvailable = false) { if (useExistingConnectionIfAvailable && context.ExistingConnection != null) { return(context.DbContextOptions.UseOracle(context.ExistingConnection, optionsBuilder => { optionsBuilder.UseQuerySplittingBehavior(QuerySplittingBehavior.SplitQuery); oracleOptionsAction?.Invoke(optionsBuilder); })); } else { return(context.DbContextOptions.UseOracle(context.ConnectionString, optionsBuilder => { optionsBuilder.UseQuerySplittingBehavior(QuerySplittingBehavior.SplitQuery); oracleOptionsAction?.Invoke(optionsBuilder); })); } }
public static DbContextOptionsBuilder UseCosmos( [NotNull] this AbpDbContextConfigurationContext context, [CanBeNull] Action <CosmosDbContextOptionsBuilder> cosmosOptionsAction = null) { //context.ConnectionStringName = "AbpBackgroundJobs" hits all the time if (context.ExistingConnection != null) { var connStringParts = context.ExistingConnection.ConnectionString.ParseConnectionString(); var accountEndpoint = connStringParts["AccountEndpoint"]; var accountKey = connStringParts["AccountKey"]; var databaseName = connStringParts["DatabaseName"]; return(context.DbContextOptions.UseCosmos(accountEndpoint: accountEndpoint, accountKey: accountKey, databaseName: databaseName, cosmosOptionsAction)); } else { var connStringParts = context.ConnectionString.ParseConnectionString(); var accountEndpoint = connStringParts["AccountEndpoint"]; var accountKey = connStringParts["AccountKey"]; var databaseName = connStringParts["DatabaseName"]; return(context.DbContextOptions.UseCosmos(accountEndpoint: accountEndpoint, accountKey: accountKey, databaseName: databaseName, cosmosOptionsAction)); } }
public static DbContextOptionsBuilder UseMySQL( [NotNull] this AbpDbContextConfigurationContext context, [CanBeNull] Action <MySqlDbContextOptionsBuilder> mySQLOptionsAction = null) { if (context.ExistingConnection != null) { return(context.DbContextOptions.UseMySql(context.ExistingConnection, ServerVersion.AutoDetect(context.ConnectionString), optionsBuilder => { optionsBuilder.UseQuerySplittingBehavior(QuerySplittingBehavior.SplitQuery); mySQLOptionsAction?.Invoke(optionsBuilder); })); } else { return(context.DbContextOptions.UseMySql(context.ConnectionString, ServerVersion.AutoDetect(context.ConnectionString), optionsBuilder => { optionsBuilder.UseQuerySplittingBehavior(QuerySplittingBehavior.SplitQuery); mySQLOptionsAction?.Invoke(optionsBuilder); })); } }
public void Configure(AbpDbContextConfigurationContext context) { Action.Invoke(context); }
public static DbContextOptionsBuilder UsePostgreSql( [NotNull] this AbpDbContextConfigurationContext context, [CanBeNull] Action <NpgsqlDbContextOptionsBuilder> postgreSqlOptionsAction = null) { return(context.UseNpgsql(postgreSqlOptionsAction)); }