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;
|
2025-01-31 23:38:38 +00:00
|
|
|
|
using Elsa.EntityFrameworkCore.Modules.Management;
|
|
|
|
|
|
using Elsa.EntityFrameworkCore.Modules.Runtime;
|
|
|
|
|
|
using Elsa.EntityFrameworkCore.Oracle.Configurations;
|
|
|
|
|
|
using Elsa.Workflows.Management.Entities;
|
|
|
|
|
|
using Elsa.Workflows.Runtime.Entities;
|
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;
|
2025-01-31 18:51:24 +00:00
|
|
|
|
|
|
|
|
|
|
public static TFeature UseOracle<TFeature, TDbContext>(this PersistenceFeatureBase<TFeature, TDbContext> feature,
|
|
|
|
|
|
string connectionString,
|
|
|
|
|
|
ElsaDbContextOptions? options = null,
|
|
|
|
|
|
Action<OracleDbContextOptionsBuilder>? configure = null)
|
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
|
|
|
|
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
|
|
|
|
}
|
2025-01-31 18:51:24 +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
|
2025-01-31 18:51:24 +00:00
|
|
|
|
)
|
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
|
|
|
|
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
|
|
|
|
}
|
2025-01-31 18:51:24 +00:00
|
|
|
|
|
|
|
|
|
|
public static TFeature UseOracle<TFeature, TDbContext>(this PersistenceFeatureBase<TFeature, TDbContext> feature,
|
|
|
|
|
|
Assembly migrationsAssembly,
|
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
|
2025-01-31 18:51:24 +00:00
|
|
|
|
)
|
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
|
|
|
|
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
|
|
|
|
}
|
2025-01-31 18:51:24 +00:00
|
|
|
|
|
|
|
|
|
|
public static TFeature UseOracle<TFeature, TDbContext>(this PersistenceFeatureBase<TFeature, TDbContext> feature,
|
|
|
|
|
|
Assembly migrationsAssembly,
|
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
|
2025-01-31 18:51:24 +00:00
|
|
|
|
)
|
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
|
|
|
|
where TDbContext : ElsaDbContextBase
|
|
|
|
|
|
where TFeature : PersistenceFeatureBase<TFeature, TDbContext>
|
|
|
|
|
|
{
|
2025-01-31 23:38:38 +00:00
|
|
|
|
options ??= new();
|
|
|
|
|
|
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
|
|
|
|
feature.DbContextOptionsBuilder = (sp, db) => db.UseElsaOracle(migrationsAssembly, connectionStringFunc(sp), options, configure: configure);
|
|
|
|
|
|
return (TFeature)feature;
|
|
|
|
|
|
}
|
2025-01-31 23:38:38 +00:00
|
|
|
|
|
|
|
|
|
|
public static ElsaDbContextOptions Configure(this ElsaDbContextOptions options)
|
|
|
|
|
|
{
|
|
|
|
|
|
var management = new Management();
|
|
|
|
|
|
var runtime = new Runtime();
|
|
|
|
|
|
|
|
|
|
|
|
options.ConfigureModel<ManagementElsaDbContext>(modelBuilder => modelBuilder
|
|
|
|
|
|
.ApplyConfiguration<WorkflowDefinition>(management)
|
|
|
|
|
|
.ApplyConfiguration<WorkflowInstance>(management));
|
|
|
|
|
|
|
|
|
|
|
|
options.ConfigureModel<RuntimeElsaDbContext>(modelBuilder => modelBuilder
|
|
|
|
|
|
.ApplyConfiguration<StoredTrigger>(runtime)
|
|
|
|
|
|
.ApplyConfiguration<WorkflowExecutionLogRecord>(runtime)
|
|
|
|
|
|
.ApplyConfiguration<ActivityExecutionRecord>(runtime)
|
|
|
|
|
|
.ApplyConfiguration<StoredBookmark>(runtime)
|
|
|
|
|
|
.ApplyConfiguration<WorkflowInboxMessage>(runtime));
|
|
|
|
|
|
|
|
|
|
|
|
return options;
|
|
|
|
|
|
}
|
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
|
|
|
|
}
|