Add configuration actions for DbContext options builders (#6110)
* Add configuration actions for DbContext options builders
Introduce a configuration delegate parameter for each database provider's `Use*` methods, enhancing customization. This change affects MySql, SqlServer, Sqlite, PostgreSql, and Oracle providers, allowing more flexible DbContext configuration.
* Add support for connection strings as functions
This update introduces new overloads to allow passing connection strings as functions that take IServiceProvider. This enhances flexibility by enabling dynamic connection string resolution at runtime. All major database providers (MySQL, SQL Server, SQLite, PostgreSQL, and Oracle) have been updated accordingly.
2024-11-11 18:01:41 +00:00
|
|
|
|
using System.Reflection;
|
2024-11-25 18:57:03 +00:00
|
|
|
|
using JetBrains.Annotations;
|
Add configuration actions for DbContext options builders (#6110)
* Add configuration actions for DbContext options builders
Introduce a configuration delegate parameter for each database provider's `Use*` methods, enhancing customization. This change affects MySql, SqlServer, Sqlite, PostgreSql, and Oracle providers, allowing more flexible DbContext configuration.
* Add support for connection strings as functions
This update introduces new overloads to allow passing connection strings as functions that take IServiceProvider. This enhances flexibility by enabling dynamic connection string resolution at runtime. All major database providers (MySQL, SQL Server, SQLite, PostgreSQL, and Oracle) have been updated accordingly.
2024-11-11 18:01:41 +00:00
|
|
|
|
using Oracle.EntityFrameworkCore.Infrastructure;
|
|
|
|
|
|
|
|
|
|
|
|
// ReSharper disable once CheckNamespace
|
|
|
|
|
|
namespace Elsa.EntityFrameworkCore.Extensions;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Provides extensions to configure EF Core to use Oracle.
|
|
|
|
|
|
/// </summary>
|
2024-11-25 18:57:03 +00:00
|
|
|
|
[PublicAPI]
|
Add configuration actions for DbContext options builders (#6110)
* Add configuration actions for DbContext options builders
Introduce a configuration delegate parameter for each database provider's `Use*` methods, enhancing customization. This change affects MySql, SqlServer, Sqlite, PostgreSql, and Oracle providers, allowing more flexible DbContext configuration.
* Add support for connection strings as functions
This update introduces new overloads to allow passing connection strings as functions that take IServiceProvider. This enhances flexibility by enabling dynamic connection string resolution at runtime. All major database providers (MySQL, SQL Server, SQLite, PostgreSQL, and Oracle) have been updated accordingly.
2024-11-11 18:01:41 +00:00
|
|
|
|
public static class OracleProvidersExtensions
|
|
|
|
|
|
{
|
|
|
|
|
|
private static Assembly Assembly => typeof(OracleProvidersExtensions).Assembly;
|
|
|
|
|
|
|
2024-11-25 18:57:03 +00:00
|
|
|
|
public static TFeature UseOracle<TFeature, TDbContext>(this PersistenceFeatureBase<TFeature, TDbContext> feature,
|
Add configuration actions for DbContext options builders (#6110)
* Add configuration actions for DbContext options builders
Introduce a configuration delegate parameter for each database provider's `Use*` methods, enhancing customization. This change affects MySql, SqlServer, Sqlite, PostgreSql, and Oracle providers, allowing more flexible DbContext configuration.
* Add support for connection strings as functions
This update introduces new overloads to allow passing connection strings as functions that take IServiceProvider. This enhances flexibility by enabling dynamic connection string resolution at runtime. All major database providers (MySQL, SQL Server, SQLite, PostgreSQL, and Oracle) have been updated accordingly.
2024-11-11 18:01:41 +00:00
|
|
|
|
string connectionString,
|
|
|
|
|
|
ElsaDbContextOptions? options = null,
|
|
|
|
|
|
Action<OracleDbContextOptionsBuilder>? configure = null)
|
|
|
|
|
|
where TDbContext : ElsaDbContextBase
|
|
|
|
|
|
where TFeature : PersistenceFeatureBase<TFeature, TDbContext>
|
|
|
|
|
|
{
|
2024-11-25 18:57:03 +00:00
|
|
|
|
return feature.UseOracle(Assembly, connectionString, options, configure);
|
Add configuration actions for DbContext options builders (#6110)
* Add configuration actions for DbContext options builders
Introduce a configuration delegate parameter for each database provider's `Use*` methods, enhancing customization. This change affects MySql, SqlServer, Sqlite, PostgreSql, and Oracle providers, allowing more flexible DbContext configuration.
* Add support for connection strings as functions
This update introduces new overloads to allow passing connection strings as functions that take IServiceProvider. This enhances flexibility by enabling dynamic connection string resolution at runtime. All major database providers (MySQL, SQL Server, SQLite, PostgreSQL, and Oracle) have been updated accordingly.
2024-11-11 18:01:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-11-25 18:57:03 +00:00
|
|
|
|
public static TFeature UseOracle<TFeature, TDbContext>(this PersistenceFeatureBase<TFeature, TDbContext> feature,
|
Add configuration actions for DbContext options builders (#6110)
* Add configuration actions for DbContext options builders
Introduce a configuration delegate parameter for each database provider's `Use*` methods, enhancing customization. This change affects MySql, SqlServer, Sqlite, PostgreSql, and Oracle providers, allowing more flexible DbContext configuration.
* Add support for connection strings as functions
This update introduces new overloads to allow passing connection strings as functions that take IServiceProvider. This enhances flexibility by enabling dynamic connection string resolution at runtime. All major database providers (MySQL, SQL Server, SQLite, PostgreSQL, and Oracle) have been updated accordingly.
2024-11-11 18:01:41 +00:00
|
|
|
|
Func<IServiceProvider, string> connectionStringFunc,
|
|
|
|
|
|
ElsaDbContextOptions? options = null,
|
|
|
|
|
|
Action<OracleDbContextOptionsBuilder>? configure = null
|
|
|
|
|
|
)
|
|
|
|
|
|
where TDbContext : ElsaDbContextBase
|
|
|
|
|
|
where TFeature : PersistenceFeatureBase<TFeature, TDbContext>
|
|
|
|
|
|
{
|
2024-11-25 18:57:03 +00:00
|
|
|
|
return feature.UseOracle(Assembly, connectionStringFunc, options, configure);
|
Add configuration actions for DbContext options builders (#6110)
* Add configuration actions for DbContext options builders
Introduce a configuration delegate parameter for each database provider's `Use*` methods, enhancing customization. This change affects MySql, SqlServer, Sqlite, PostgreSql, and Oracle providers, allowing more flexible DbContext configuration.
* Add support for connection strings as functions
This update introduces new overloads to allow passing connection strings as functions that take IServiceProvider. This enhances flexibility by enabling dynamic connection string resolution at runtime. All major database providers (MySQL, SQL Server, SQLite, PostgreSQL, and Oracle) have been updated accordingly.
2024-11-11 18:01:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-11-25 18:57:03 +00:00
|
|
|
|
public static TFeature UseOracle<TFeature, TDbContext>(this PersistenceFeatureBase<TFeature, TDbContext> feature,
|
Add configuration actions for DbContext options builders (#6110)
* Add configuration actions for DbContext options builders
Introduce a configuration delegate parameter for each database provider's `Use*` methods, enhancing customization. This change affects MySql, SqlServer, Sqlite, PostgreSql, and Oracle providers, allowing more flexible DbContext configuration.
* Add support for connection strings as functions
This update introduces new overloads to allow passing connection strings as functions that take IServiceProvider. This enhances flexibility by enabling dynamic connection string resolution at runtime. All major database providers (MySQL, SQL Server, SQLite, PostgreSQL, and Oracle) have been updated accordingly.
2024-11-11 18:01:41 +00:00
|
|
|
|
Assembly migrationsAssembly,
|
|
|
|
|
|
string connectionString,
|
|
|
|
|
|
ElsaDbContextOptions? options = null,
|
|
|
|
|
|
Action<OracleDbContextOptionsBuilder>? configure = null
|
|
|
|
|
|
)
|
|
|
|
|
|
where TDbContext : ElsaDbContextBase
|
|
|
|
|
|
where TFeature : PersistenceFeatureBase<TFeature, TDbContext>
|
|
|
|
|
|
{
|
2024-11-25 18:57:03 +00:00
|
|
|
|
return feature.UseOracle(migrationsAssembly, _ => connectionString, options, configure);
|
Add configuration actions for DbContext options builders (#6110)
* Add configuration actions for DbContext options builders
Introduce a configuration delegate parameter for each database provider's `Use*` methods, enhancing customization. This change affects MySql, SqlServer, Sqlite, PostgreSql, and Oracle providers, allowing more flexible DbContext configuration.
* Add support for connection strings as functions
This update introduces new overloads to allow passing connection strings as functions that take IServiceProvider. This enhances flexibility by enabling dynamic connection string resolution at runtime. All major database providers (MySQL, SQL Server, SQLite, PostgreSQL, and Oracle) have been updated accordingly.
2024-11-11 18:01:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-11-25 18:57:03 +00:00
|
|
|
|
public static TFeature UseOracle<TFeature, TDbContext>(this PersistenceFeatureBase<TFeature, TDbContext> feature,
|
Add configuration actions for DbContext options builders (#6110)
* Add configuration actions for DbContext options builders
Introduce a configuration delegate parameter for each database provider's `Use*` methods, enhancing customization. This change affects MySql, SqlServer, Sqlite, PostgreSql, and Oracle providers, allowing more flexible DbContext configuration.
* Add support for connection strings as functions
This update introduces new overloads to allow passing connection strings as functions that take IServiceProvider. This enhances flexibility by enabling dynamic connection string resolution at runtime. All major database providers (MySQL, SQL Server, SQLite, PostgreSQL, and Oracle) have been updated accordingly.
2024-11-11 18:01:41 +00:00
|
|
|
|
Assembly migrationsAssembly,
|
|
|
|
|
|
Func<IServiceProvider, string> connectionStringFunc,
|
|
|
|
|
|
ElsaDbContextOptions? options = null,
|
|
|
|
|
|
Action<OracleDbContextOptionsBuilder>? configure = null
|
|
|
|
|
|
)
|
|
|
|
|
|
where TDbContext : ElsaDbContextBase
|
|
|
|
|
|
where TFeature : PersistenceFeatureBase<TFeature, TDbContext>
|
|
|
|
|
|
{
|
|
|
|
|
|
feature.DbContextOptionsBuilder = (sp, db) => db.UseElsaOracle(migrationsAssembly, connectionStringFunc(sp), options, configure: configure);
|
|
|
|
|
|
return (TFeature)feature;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|