81 lines
4.1 KiB
C#
81 lines
4.1 KiB
C#
|
|
using System.Reflection;
|
|||
|
|
using Elsa.EntityFrameworkCore.Common;
|
|||
|
|
using Elsa.EntityFrameworkCore.Modules.Alterations;
|
|||
|
|
using Elsa.EntityFrameworkCore.Modules.Identity;
|
|||
|
|
using Elsa.EntityFrameworkCore.Modules.Labels;
|
|||
|
|
using Elsa.EntityFrameworkCore.Modules.Management;
|
|||
|
|
using Elsa.EntityFrameworkCore.Modules.Runtime;
|
|||
|
|
|
|||
|
|
// ReSharper disable once CheckNamespace
|
|||
|
|
namespace Elsa.EntityFrameworkCore.Extensions;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Provides extensions to configure EF Core to use Sqlite.
|
|||
|
|
/// </summary>
|
|||
|
|
public static class SqliteProvidersExtensions
|
|||
|
|
{
|
|||
|
|
private static Assembly Assembly => typeof(SqliteProvidersExtensions).Assembly;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Configures the <see cref="EFCoreIdentityPersistenceFeature"/> to use Sqlite.
|
|||
|
|
/// </summary>
|
|||
|
|
public static EFCoreIdentityPersistenceFeature UseSqlite(this EFCoreIdentityPersistenceFeature feature, string connectionString = Constants.DefaultConnectionString, ElsaDbContextOptions? options = default)
|
|||
|
|
{
|
|||
|
|
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaSqlite(Assembly, connectionString, options);
|
|||
|
|
return feature;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Configures the <see cref="EFCoreAlterationsPersistenceFeature"/> to use Sqlite.
|
|||
|
|
/// </summary>
|
|||
|
|
public static EFCoreAlterationsPersistenceFeature UseSqlite(this EFCoreAlterationsPersistenceFeature feature, string connectionString = Constants.DefaultConnectionString, ElsaDbContextOptions? options = default)
|
|||
|
|
{
|
|||
|
|
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaSqlite(Assembly, connectionString, options);
|
|||
|
|
return feature;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Configures the <see cref="EFCoreLabelPersistenceFeature"/> to use Sqlite.
|
|||
|
|
/// </summary>
|
|||
|
|
public static EFCoreLabelPersistenceFeature UseSqlite(this EFCoreLabelPersistenceFeature feature, string connectionString = Constants.DefaultConnectionString, ElsaDbContextOptions? options = default)
|
|||
|
|
{
|
|||
|
|
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaSqlite(Assembly, connectionString, options);
|
|||
|
|
return feature;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Configures the <see cref="EFCoreWorkflowDefinitionPersistenceFeature"/> to use Sqlite.
|
|||
|
|
/// </summary>
|
|||
|
|
public static EFCoreWorkflowDefinitionPersistenceFeature UseSqlite(this EFCoreWorkflowDefinitionPersistenceFeature feature, string connectionString = Constants.DefaultConnectionString, ElsaDbContextOptions? options = default)
|
|||
|
|
{
|
|||
|
|
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaSqlite(Assembly, connectionString, options);
|
|||
|
|
return feature;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Configures the <see cref="EFCoreWorkflowInstancePersistenceFeature"/> to use Sqlite.
|
|||
|
|
/// </summary>
|
|||
|
|
public static EFCoreWorkflowInstancePersistenceFeature UseSqlite(this EFCoreWorkflowInstancePersistenceFeature feature, string connectionString = Constants.DefaultConnectionString, ElsaDbContextOptions? options = default)
|
|||
|
|
{
|
|||
|
|
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaSqlite(Assembly, connectionString, options);
|
|||
|
|
return feature;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Configures the <see cref="WorkflowManagementPersistenceFeature"/> to use Sqlite.
|
|||
|
|
/// </summary>
|
|||
|
|
public static WorkflowManagementPersistenceFeature UseSqlite(this WorkflowManagementPersistenceFeature feature, string connectionString = Constants.DefaultConnectionString, ElsaDbContextOptions? options = default)
|
|||
|
|
{
|
|||
|
|
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaSqlite(Assembly, connectionString, options);
|
|||
|
|
return feature;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Configures the <see cref="EFCoreWorkflowRuntimePersistenceFeature"/> to use Sqlite.
|
|||
|
|
/// </summary>
|
|||
|
|
public static EFCoreWorkflowRuntimePersistenceFeature UseSqlite(this EFCoreWorkflowRuntimePersistenceFeature feature, string connectionString = Constants.DefaultConnectionString, ElsaDbContextOptions? options = default)
|
|||
|
|
{
|
|||
|
|
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaSqlite(Assembly, connectionString, options);
|
|||
|
|
return feature;
|
|||
|
|
}
|
|||
|
|
}
|