You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using MongoDB persistence with user-defined data classes, you need to configure which types are allowed to be deserialized. This is done via the `serializerTypeFilter` parameter:
- All default MongoDB allowed types (primitives, collections, etc.)
36
+
- Types in your application namespace (e.g., `MyApp.*`)
37
+
38
+
**Important:** You must configure the serializer to allow your workflow data types, otherwise you will encounter a `BsonSerializationException` when MongoDB tries to deserialize your data.
39
+
40
+
Example for multiple namespaces:
41
+
42
+
```C#
43
+
services.AddWorkflow(x=>x.UseMongoDB(
44
+
@"mongodb://localhost:27017",
45
+
"workflow",
46
+
serializerTypeFilter: type=>
47
+
{
48
+
if (MongoDB.Bson.Serialization.Serializers.ObjectSerializer.DefaultAllowedTypes(type))
49
+
returntrue;
50
+
51
+
varfullName=type.FullName??"";
52
+
returnfullName.StartsWith("MyApp.") ||
53
+
fullName.StartsWith("MyCompany.Models.") ||
54
+
fullName.StartsWith("WorkflowCore.");
55
+
}));
56
+
```
57
+
21
58
### State object serialization
22
59
23
60
By default (to maintain backwards compatibility), the state object is serialized using a two step serialization process using object -> JSON -> BSON serialization.
0 commit comments