Automatic deserialization $type #13842
-
I have this property in one of my classes (this is how it's stored in RavenDB) "Settings": {
"$type": "System.Collections.Generic.Dictionary`2[[System.String, mscorlib],[System.Object, mscorlib]], mscorlib",
"lastUsedUnitId": {
"1": "units-3368",
"$type": "System.Collections.Generic.Dictionary`2[[System.Int32, mscorlib],[System.String, mscorlib]], mscorlib"
}
} The C# property looks like this public Dictionary<string, object> Settings { get; set; } I assume (I think this is how this worked until recently) that Is there any way that this conversion can be done automatically? Am I missing something? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 26 replies
-
Hi, can you give us more information about which version of RavenDB Client and .NET you use? I tried to reproduce it ( https://gist.github.com/maciejaszyk/ca4fecd932c322dca787ba6d673752fb ), but the test works just fine. |
Beta Was this translation helpful? Give feedback.
-
Okay, that took way too long to figure out, but now I have a good handle on what is going on here. This will not work:
This, on the other hand, will:
The key difference between those two, the
|
Beta Was this translation helpful? Give feedback.
-
@ayende But the fix is very unhelpful. Are you avoiding creating the fix of the JSON editor because it's too hard to change the algorithm for formatting? Or is there some other issue? I can imagine how easy might be to just skip the formatting function of the editor before saving when you detect that there is numeric key? I also tried to fix the document with this script and it doesn't change the document if I don't change '-A' to '-a'. from Users
where id()='users-3073-b'
update {
this.Settings["lastUsedUnitId"] = {
"$type": "System.Collections.Generic.Dictionary`2[[System.Int32, mscorlib],[System.String, mscorlib]], mscorlib",
"1": "units-14887-A"
};
} Which is extremely weird. Is that how patch is supposed to work? Not change the doc if the change is only in the ordering of the properties? |
Beta Was this translation helpful? Give feedback.
Okay, that took way too long to figure out, but now I have a good handle on what is going on here.
This will not work:
This, on the other hand, will: