Skip to content

Commit 548c8c0

Browse files
Copilotdanielgerlag
andcommitted
Add ObjectSerializer registration in MongoDB persistence provider
Co-authored-by: danielgerlag <[email protected]>
1 parent 6881dcf commit 548c8c0

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/providers/WorkflowCore.Persistence.MongoDB/Services/MongoPersistenceProvider.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ public MongoPersistenceProvider(IMongoDatabase database)
2727

2828
static MongoPersistenceProvider()
2929
{
30+
// Register ObjectSerializer to allow deserialization of WorkflowCore types and user types
31+
// This matches the pattern used in MongoDB tests which resolves serialization issues
32+
BsonSerializer.TryRegisterSerializer(new ObjectSerializer(type =>
33+
ObjectSerializer.DefaultAllowedTypes(type) ||
34+
type.FullName?.StartsWith("WorkflowCore") == true));
35+
3036
ConventionRegistry.Register(
3137
"workflow.conventions",
3238
new ConventionPack

src/samples/WorkflowCore.Sample04/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ private static IServiceProvider ConfigureServices()
3333
//setup dependency injection
3434
IServiceCollection services = new ServiceCollection();
3535
services.AddLogging();
36-
services.AddWorkflow();
37-
//services.AddWorkflow(x => x.UseMongoDB(@"mongodb://localhost:27017", "workflow"));
36+
//services.AddWorkflow();
37+
services.AddWorkflow(x => x.UseMongoDB(@"mongodb://localhost:27017", "workflow"));
3838
//services.AddWorkflow(x => x.UseSqlServer(@"Server=.;Database=WorkflowCore;Trusted_Connection=True;", true, true));
3939
//services.AddWorkflow(x => x.UsePostgreSQL(@"Server=127.0.0.1;Port=5432;Database=workflow;User Id=postgres;", true, true));
4040
//services.AddWorkflow(x => x.UseSqlite(@"Data Source=database.db;", true));

0 commit comments

Comments
 (0)