diff --git a/src/modules/Elsa.EntityFrameworkCore/Common/ElsaDbContextBase.cs b/src/modules/Elsa.EntityFrameworkCore/Common/ElsaDbContextBase.cs
index 68aa7ae16..b19245fc7 100644
--- a/src/modules/Elsa.EntityFrameworkCore/Common/ElsaDbContextBase.cs
+++ b/src/modules/Elsa.EntityFrameworkCore/Common/ElsaDbContextBase.cs
@@ -1,4 +1,5 @@
using Elsa.EntityFrameworkCore.Extensions;
+using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
@@ -7,17 +8,18 @@ namespace Elsa.EntityFrameworkCore.Common;
///
/// An optional base class to implement with some opinions on certain converters to install for certain DB providers.
///
+[PublicAPI]
public abstract class ElsaDbContextBase : DbContext
{
///
/// The schema used by Elsa.
///
- public static string ElsaSchema = "Elsa";
+ public static string ElsaSchema { get; set; } = "Elsa";
///
/// The table used to store the migrations history.
///
- public static string MigrationsHistoryTable = "__EFMigrationsHistory";
+ public static string MigrationsHistoryTable { get; set; } = "__EFMigrationsHistory";
///
/// Initializes a new instance of the class.
@@ -25,6 +27,8 @@ public abstract class ElsaDbContextBase : DbContext
protected ElsaDbContextBase(DbContextOptions options) : base(options)
{
var elsaDbContextOptions = options.FindExtension()?.Options;
+
+ // ReSharper disable once VirtualMemberCallInConstructor
Schema = !string.IsNullOrWhiteSpace(elsaDbContextOptions?.SchemaName) ? elsaDbContextOptions.SchemaName : ElsaSchema;
}
diff --git a/src/modules/Elsa.EntityFrameworkCore/Common/ElsaDbContextOptions.cs b/src/modules/Elsa.EntityFrameworkCore/Common/ElsaDbContextOptions.cs
index 7f0c77c15..b67834f9c 100644
--- a/src/modules/Elsa.EntityFrameworkCore/Common/ElsaDbContextOptions.cs
+++ b/src/modules/Elsa.EntityFrameworkCore/Common/ElsaDbContextOptions.cs
@@ -1,8 +1,25 @@
+using JetBrains.Annotations;
+
namespace Elsa.EntityFrameworkCore.Common;
+///
+/// Provides options for configuring Elsa's Entity Framework Core integration.
+///
+[PublicAPI]
public class ElsaDbContextOptions
{
+ ///
+ /// The schema used by Elsa.
+ ///
public string? SchemaName { get; set; }
+
+ ///
+ /// The table used to store the migrations history.
+ ///
public string? MigrationsHistoryTableName { get; set; }
+
+ ///
+ /// The assembly name containing the migrations.
+ ///
public string? MigrationsAssemblyName { get; set; }
}
diff --git a/src/modules/Elsa.EntityFrameworkCore/Common/ElsaDbContextOptionsExtensions.cs b/src/modules/Elsa.EntityFrameworkCore/Common/ElsaDbContextOptionsExtensions.cs
index dd5a41f88..4b0883e57 100644
--- a/src/modules/Elsa.EntityFrameworkCore/Common/ElsaDbContextOptionsExtensions.cs
+++ b/src/modules/Elsa.EntityFrameworkCore/Common/ElsaDbContextOptionsExtensions.cs
@@ -3,15 +3,19 @@ using Microsoft.EntityFrameworkCore.Infrastructure;
namespace Elsa.EntityFrameworkCore.Common;
+///
+/// Provides options for configuring Elsa's Entity Framework Core integration.
+///
public static class ElsaDbContextOptionsExtensions
{
- public static DbContextOptionsBuilder UseElsaDbContextOptions(
- this DbContextOptionsBuilder optionsBuilder,
- ElsaDbContextOptions? options)
+ ///
+ /// Installs a custom extension for Elsa's Entity Framework Core integration.
+ ///
+ /// The options builder to install the extension on.
+ /// The options to install.
+ public static DbContextOptionsBuilder UseElsaDbContextOptions(this DbContextOptionsBuilder optionsBuilder, ElsaDbContextOptions? options)
{
- ((IDbContextOptionsBuilderInfrastructure)optionsBuilder).AddOrUpdateExtension(
- new ElsaDbContextOptionsExtension(options));
-
+ ((IDbContextOptionsBuilderInfrastructure)optionsBuilder).AddOrUpdateExtension(new ElsaDbContextOptionsExtension(options));
return optionsBuilder;
}
}
diff --git a/src/modules/Elsa.EntityFrameworkCore/Common/PersistenceFeatureBase.cs b/src/modules/Elsa.EntityFrameworkCore/Common/PersistenceFeatureBase.cs
index 5f7659086..75c32671b 100644
--- a/src/modules/Elsa.EntityFrameworkCore/Common/PersistenceFeatureBase.cs
+++ b/src/modules/Elsa.EntityFrameworkCore/Common/PersistenceFeatureBase.cs
@@ -6,27 +6,48 @@ using Microsoft.Extensions.DependencyInjection;
namespace Elsa.EntityFrameworkCore.Common;
+///
+/// Base class for features that require Entity Framework Core.
+///
+/// The type of the database context.
public abstract class PersistenceFeatureBase : FeatureBase where TDbContext : DbContext
{
+ ///
protected PersistenceFeatureBase(IModule module) : base(module)
{
}
+ ///
+ /// Gets or sets a value indicating whether to use context pooling.
+ ///
public bool UseContextPooling { get; set; }
+
+ ///
+ /// Gets or sets a value indicating whether to run migrations.
+ ///
public bool RunMigrations { get; set; } = true;
+
+ ///
+ /// Gets or sets the lifetime of the . Defaults to .
+ ///
public ServiceLifetime DbContextFactoryLifetime { get; set; } = ServiceLifetime.Singleton;
+ ///
+ /// Gets or sets the callback used to configure the .
+ ///
public Action DbContextOptionsBuilder = (_, options) => options
.UseSqlite("Data Source=elsa.sqlite.db;Cache=Shared;", sqlite => sqlite
.MigrationsAssembly("Elsa.EntityFrameworkCore.Sqlite")
.MigrationsHistoryTable(ElsaDbContextBase.MigrationsHistoryTable, ElsaDbContextBase.ElsaSchema));
+ ///
public override void ConfigureHostedServices()
{
if (RunMigrations)
Module.ConfigureHostedService>(-100); // Migrations need to run before other hosted services that depend on DB access.
}
+ ///
public override void Apply()
{
if (UseContextPooling)
@@ -35,6 +56,11 @@ public abstract class PersistenceFeatureBase : FeatureBase where TDb
Services.AddDbContextFactory(DbContextOptionsBuilder, DbContextFactoryLifetime);
}
+ ///
+ /// Adds a store to the service collection.
+ ///
+ /// The type of the entity.
+ /// The type of the store.
protected void AddStore() where TEntity : class where TStore : class
{
Services
@@ -43,6 +69,11 @@ public abstract class PersistenceFeatureBase : FeatureBase where TDb
;
}
+ ///
+ /// Adds an entity store to the service collection.
+ ///
+ /// The type of the entity.
+ /// The type of the store.
protected void AddEntityStore() where TEntity : Entity where TStore : class
{
Services
diff --git a/src/modules/Elsa.EntityFrameworkCore/Common/RunMigrationsHostedService.cs b/src/modules/Elsa.EntityFrameworkCore/Common/RunMigrationsHostedService.cs
index dff3cbc0e..b0f437c95 100644
--- a/src/modules/Elsa.EntityFrameworkCore/Common/RunMigrationsHostedService.cs
+++ b/src/modules/Elsa.EntityFrameworkCore/Common/RunMigrationsHostedService.cs
@@ -9,8 +9,13 @@ namespace Elsa.EntityFrameworkCore.Common;
public class RunMigrationsHostedService : IHostedService where TDbContext : DbContext
{
private readonly IDbContextFactory _dbContextFactory;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
public RunMigrationsHostedService(IDbContextFactory dbContextFactoryFactory) => _dbContextFactory = dbContextFactoryFactory;
+ ///
public async Task StartAsync(CancellationToken cancellationToken)
{
await using var dbContext = await _dbContextFactory.CreateDbContextAsync(cancellationToken);
@@ -18,5 +23,6 @@ public class RunMigrationsHostedService : IHostedService where TDbCo
await dbContext.DisposeAsync();
}
+ ///
public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask;
}
\ No newline at end of file
diff --git a/src/modules/Elsa.EntityFrameworkCore/Extensions/ExpressionExtensions.cs b/src/modules/Elsa.EntityFrameworkCore/Extensions/ExpressionExtensions.cs
index 967bac00f..afaea4650 100644
--- a/src/modules/Elsa.EntityFrameworkCore/Extensions/ExpressionExtensions.cs
+++ b/src/modules/Elsa.EntityFrameworkCore/Extensions/ExpressionExtensions.cs
@@ -3,8 +3,18 @@ using Elsa.Extensions;
namespace Elsa.EntityFrameworkCore.Extensions;
+///
+/// Provides extension methods for objects.
+///
public static class ExpressionExtensions
{
+ ///
+ /// Builds an expression that checks if the specified property is contained in the specified list of entities.
+ ///
+ /// The key selector.
+ /// The entities.
+ /// The type of the entity.
+ /// The expression.
public static Expression> BuildContainsExpression(this Expression> keySelector, IEnumerable entities) where TEntity : class
{
var compiledKeySelector = keySelector.Compile();
@@ -21,7 +31,14 @@ public static class ExpressionExtensions
return Expression.Lambda>(body, param);
}
- public static Expression> BuildEqualsExpresion(this Expression> keySelector, TEntity entity)
+ ///
+ /// Builds an expression that checks if the specified property is equal to the specified entity's property.
+ ///
+ /// The key selector.
+ /// The entity.
+ /// The type of the entity.
+ /// The expression.
+ public static Expression> BuildEqualsExpression(this Expression> keySelector, TEntity entity)
{
var keyName = keySelector.GetProperty()!.Name;
diff --git a/src/modules/Elsa.EntityFrameworkCore/Extensions/QueryableExtensions.cs b/src/modules/Elsa.EntityFrameworkCore/Extensions/QueryableExtensions.cs
index bd53c4696..37dcfe824 100644
--- a/src/modules/Elsa.EntityFrameworkCore/Extensions/QueryableExtensions.cs
+++ b/src/modules/Elsa.EntityFrameworkCore/Extensions/QueryableExtensions.cs
@@ -1,5 +1,6 @@
using System.Linq.Expressions;
using Elsa.Common.Models;
+using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore;
namespace Elsa.EntityFrameworkCore.Extensions;
@@ -7,6 +8,7 @@ namespace Elsa.EntityFrameworkCore.Extensions;
///
/// Provides extensions to .
///
+[PublicAPI]
public static class QueryableExtensions
{
///
diff --git a/src/samples/aspnet/Elsa.Samples.AspNet.DslWorkflowProvider/Program.cs b/src/samples/aspnet/Elsa.Samples.AspNet.DslWorkflowProvider/Program.cs
index cb7e0ae63..52e672aa9 100644
--- a/src/samples/aspnet/Elsa.Samples.AspNet.DslWorkflowProvider/Program.cs
+++ b/src/samples/aspnet/Elsa.Samples.AspNet.DslWorkflowProvider/Program.cs
@@ -18,7 +18,7 @@ services.AddElsa(elsa => elsa
management.UseEntityFrameworkCore();
management.UseDslIntegration(dsl =>
{
- dsl.MapActivityFunction("println", nameof(WriteLine), new[] { nameof(WriteLine.Text) });
+ dsl.MapActivityFunction("print", nameof(WriteLine), new[] { nameof(WriteLine.Text) });
dsl.MapActivityFunction("http_listen", nameof(HttpEndpoint), new[] { nameof(HttpEndpoint.Path), nameof(HttpEndpoint.SupportedMethods) }, activity => activity.SetCanStartWorkflow(true));
dsl.MapActivityFunction("http_write", nameof(WriteHttpResponse), new[] { nameof(WriteHttpResponse.StatusCode), nameof(WriteHttpResponse.Content) });
});
diff --git a/src/samples/aspnet/Elsa.Samples.AspNet.DslWorkflowProvider/Workflows/hello-world-functional.elsa b/src/samples/aspnet/Elsa.Samples.AspNet.DslWorkflowProvider/Workflows/hello-world-functional.elsa
index 7c6b5b7fd..f540889b4 100644
--- a/src/samples/aspnet/Elsa.Samples.AspNet.DslWorkflowProvider/Workflows/hello-world-functional.elsa
+++ b/src/samples/aspnet/Elsa.Samples.AspNet.DslWorkflowProvider/Workflows/hello-world-functional.elsa
@@ -2,7 +2,7 @@
http_listen("hello-world-functional-dsl", ["GET"]);
// Print a message to the console.
-println("Hello functional DSL World!");
+print("Hello functional DSL World!");
// Write an HTTP response.
http_write("200", "Hello functional DSL World!");
\ No newline at end of file