Reverse WorkflowInstanceEntity.Scopes on deserialization (#342)

There is a known issue in Newtonsoft.Json is reversing the stack after deserialization we have to manually reversing it.
This commit is contained in:
Ibrahim Hammad 2020-07-14 15:25:00 +02:00 committed by GitHub
parent 2cfb7d302e
commit 900d179c9f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -94,7 +94,7 @@ namespace Elsa.Persistence.EntityFrameworkCore.DbContexts
.Property(x => x.Scopes)
.HasConversion(
x => Serialize(x),
x => Deserialize<Stack<WorkflowExecutionScope>>(x)
x => DeserializeScopes(x)
);
entity
@ -176,5 +176,11 @@ namespace Elsa.Persistence.EntityFrameworkCore.DbContexts
{
return JsonConvert.DeserializeObject<T>(json, serializerSettings);
}
private Stack<WorkflowExecutionScope> DeserializeScopes(string json)
{
var reversedScopes = JsonConvert.DeserializeObject<Stack<WorkflowExecutionScope>>(json, serializerSettings);
return reversedScopes is { } ? new Stack<WorkflowExecutionScope>(reversedScopes) : null;
}
}
}