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
{{ message }}
This repository has been archived by the owner on Jul 9, 2023. It is now read-only.
However, when we deserialize the State field back, it comes as a JObject because Json.Net doesn't know the proper type to deserialize to. That can be fixed if we use a custom JsonSerializerSettings object when initializing the DocumentClient and tell it to include the Type to the object serialized. I tried that, and when sending back the document to the database with that settings applied, the sproc parameters are all undefined.
To workaround the deserialization issue, I introduced the workaround here.
Just logging this issue so we can investigate how to properly use the JsonSerializerSettings and avoid the call to JObject.ToObject<T>() when deserializing the state.
The text was updated successfully, but these errors were encountered:
I took at look at this, and was really struggling to find the right combination of settings to get this to work.
Previously I was able to supply JsonSerializerSettings to the DocumentClient with TypeNameHandling set to all. However, doing this while using stored procedures resulted in the parameters always being undefined within the stored procedure. I also tried TypeNameHandling.Objects and TypeNameHandling.Auto with a little more success. In the latter 2 cases, the $type property was properly saved with the document. But, when deserializing, the $type information seemed to be getting ignored, and the resulting State property would always be a JObject.
I also tried setting MetadataPropertyHandling to ReadForward, thinking the $type property wasn't coming in first, but to no avail.
Yeah, that is precisely the behavior I had... If we don't find out, I'll open a ticket on Azure support team as DocDB package isn't OSSed unfortunatelly.
Since the State payload is serialized as
object
, it goes just fine inside theStateEntity
in CosmosDB as you may see in the following sample:However, when we deserialize the
State
field back, it comes as aJObject
because Json.Net doesn't know the proper type to deserialize to. That can be fixed if we use a customJsonSerializerSettings
object when initializing theDocumentClient
and tell it to include the Type to the object serialized. I tried that, and when sending back the document to the database with that settings applied, the sproc parameters are allundefined
.To workaround the deserialization issue, I introduced the workaround here.
Just logging this issue so we can investigate how to properly use the
JsonSerializerSettings
and avoid the call toJObject.ToObject<T>()
when deserializing the state.The text was updated successfully, but these errors were encountered: