diff --git a/src/modules/Elsa.Dapper/Modules/Runtime/Stores/DapperWorkflowInboxStore.cs b/src/modules/Elsa.Dapper/Modules/Runtime/Stores/DapperWorkflowInboxStore.cs
index 54226593c..5c5d8097f 100644
--- a/src/modules/Elsa.Dapper/Modules/Runtime/Stores/DapperWorkflowInboxStore.cs
+++ b/src/modules/Elsa.Dapper/Modules/Runtime/Stores/DapperWorkflowInboxStore.cs
@@ -43,23 +43,42 @@ public class DapperWorkflowInboxStore : IWorkflowInboxStore
var records = await _store.FindManyAsync(q => ApplyFilter(q, filter), cancellationToken);
return Map(records);
}
-
+
+ ///
+ public async ValueTask> FindManyAsync(IEnumerable filters, CancellationToken cancellationToken = default)
+ {
+ var records = await _store.FindManyAsync(q => ApplyFilter(q, filters.ToArray()), cancellationToken);
+ return Map(records);
+ }
+
///
public async ValueTask DeleteAsync(WorkflowInboxMessageFilter filter, CancellationToken cancellationToken = default)
{
return await _store.DeleteAsync(q => ApplyFilter(q, filter), cancellationToken);
}
- private void ApplyFilter(ParameterizedQuery query, WorkflowInboxMessageFilter filter)
+ private void ApplyFilter(ParameterizedQuery query, params WorkflowInboxMessageFilter[] filters)
{
- query
- .Is(nameof(WorkflowInboxMessageRecord.Hash), filter.Hash)
- .Is(nameof(WorkflowInboxMessageRecord.WorkflowInstanceId), filter.WorkflowInstanceId)
- .Is(nameof(WorkflowInboxMessageRecord.CorrelationId), filter.CorrelationId)
- .Is(nameof(WorkflowInboxMessageRecord.ActivityTypeName), filter.ActivityTypeName)
- .Is(nameof(WorkflowInboxMessageRecord.ActivityInstanceId), filter.ActivityInstanceId)
- .Is(nameof(WorkflowInboxMessageRecord.IsHandled), filter.IsHandled)
- ;
+ var clauses = new List();
+
+ foreach (var filter in filters)
+ {
+ var clause = new ParameterizedQuery(query.Dialect);
+
+ clause
+ .Is(nameof(WorkflowInboxMessageRecord.Hash), filter.Hash)
+ .Is(nameof(WorkflowInboxMessageRecord.WorkflowInstanceId), filter.WorkflowInstanceId)
+ .Is(nameof(WorkflowInboxMessageRecord.CorrelationId), filter.CorrelationId)
+ .Is(nameof(WorkflowInboxMessageRecord.ActivityTypeName), filter.ActivityTypeName)
+ .Is(nameof(WorkflowInboxMessageRecord.ActivityInstanceId), filter.ActivityInstanceId)
+ .Is(nameof(WorkflowInboxMessageRecord.IsHandled), filter.IsHandled)
+ ;
+
+ clauses.Add(clause);
+ }
+
+ var clausesSql = string.Join(" OR ", $"({clauses.Select(x => x.Sql)})");
+ query.Sql.AppendLine(clausesSql);
}
private IEnumerable Map(IEnumerable source) => source.Select(Map);
diff --git a/src/modules/Elsa.EntityFrameworkCore/Modules/Runtime/WorkflowInboxStore.cs b/src/modules/Elsa.EntityFrameworkCore/Modules/Runtime/WorkflowInboxStore.cs
index dea7fe9df..18f0c192d 100644
--- a/src/modules/Elsa.EntityFrameworkCore/Modules/Runtime/WorkflowInboxStore.cs
+++ b/src/modules/Elsa.EntityFrameworkCore/Modules/Runtime/WorkflowInboxStore.cs
@@ -30,6 +30,16 @@ public class EFCoreWorkflowInboxStore : IWorkflowInboxStore
///
public async ValueTask> FindManyAsync(WorkflowInboxMessageFilter filter, CancellationToken cancellationToken = default) => await _store.QueryAsync(filter.Apply, LoadAsync, cancellationToken);
+ ///
+ public async ValueTask> FindManyAsync(IEnumerable filters, CancellationToken cancellationToken = default)
+ {
+ return await _store.QueryAsync(query =>
+ {
+ foreach (var filter in filters) filter.Apply(query);
+ return query;
+ }, LoadAsync, cancellationToken);
+ }
+
///
public async ValueTask DeleteAsync(WorkflowInboxMessageFilter filter, CancellationToken cancellationToken = default) => await _store.DeleteWhereAsync(filter.Apply, cancellationToken);
diff --git a/src/modules/Elsa.MongoDb/Modules/Runtime/WorkflowInboxStore.cs b/src/modules/Elsa.MongoDb/Modules/Runtime/WorkflowInboxStore.cs
index 7945c506a..dda0b3b7c 100644
--- a/src/modules/Elsa.MongoDb/Modules/Runtime/WorkflowInboxStore.cs
+++ b/src/modules/Elsa.MongoDb/Modules/Runtime/WorkflowInboxStore.cs
@@ -22,17 +22,28 @@ public class MongoWorkflowInboxStore : IWorkflowInboxStore
}
///
- public async ValueTask SaveAsync(WorkflowInboxMessage record, CancellationToken cancellationToken = default) =>
+ public async ValueTask SaveAsync(WorkflowInboxMessage record, CancellationToken cancellationToken = default) =>
await _mongoDbStore.SaveAsync(record, s => s.Id, cancellationToken);
///
- public async ValueTask> FindManyAsync(WorkflowInboxMessageFilter filter, CancellationToken cancellationToken = default) =>
- (await _mongoDbStore.FindManyAsync(query => Filter(query, filter), cancellationToken));
+ public async ValueTask> FindManyAsync(WorkflowInboxMessageFilter filter, CancellationToken cancellationToken = default)
+ {
+ return await _mongoDbStore.FindManyAsync(query => Filter(query, filter), cancellationToken);
+ }
///
- public async ValueTask DeleteAsync(WorkflowInboxMessageFilter filter, CancellationToken cancellationToken = default) =>
+ public async ValueTask> FindManyAsync(IEnumerable filters, CancellationToken cancellationToken = default)
+ {
+ return await _mongoDbStore.FindManyAsync(query => Filter(query, filters.ToArray()), cancellationToken);
+ }
+
+ ///
+ public async ValueTask DeleteAsync(WorkflowInboxMessageFilter filter, CancellationToken cancellationToken = default) =>
await _mongoDbStore.DeleteWhereAsync(query => Filter(query, filter), x => x.Id, cancellationToken);
- private IMongoQueryable Filter(IMongoQueryable queryable, WorkflowInboxMessageFilter filter) =>
- (filter.Apply(queryable) as IMongoQueryable)!;
+ private static IMongoQueryable Filter(IMongoQueryable queryable, params WorkflowInboxMessageFilter[] filters)
+ {
+ foreach (var filter in filters) filter.Apply(queryable);
+ return queryable;
+ }
}
\ No newline at end of file
diff --git a/src/modules/Elsa.Workflows.Core/Activities/ForEach.cs b/src/modules/Elsa.Workflows.Core/Activities/ForEach.cs
index ac31950dc..92895095c 100644
--- a/src/modules/Elsa.Workflows.Core/Activities/ForEach.cs
+++ b/src/modules/Elsa.Workflows.Core/Activities/ForEach.cs
@@ -1,10 +1,4 @@
-using System.Runtime.CompilerServices;
-using Elsa.Expressions.Models;
-using Elsa.Extensions;
using Elsa.Workflows.Core.Attributes;
-using Elsa.Workflows.Core.Behaviors;
-using Elsa.Workflows.Core.Contracts;
-using Elsa.Workflows.Core.Models;
using JetBrains.Annotations;
namespace Elsa.Workflows.Core.Activities;
@@ -13,123 +7,6 @@ namespace Elsa.Workflows.Core.Activities;
/// Iterate over a set of values.
///
[Activity("Elsa", "Looping", "Iterate over a set of values.")]
-[PublicAPI]
-public class ForEach : Activity
+public class ForEach : ForEach