Object references not always serializing correctly

19 просмотров
Перейти к первому непрочитанному сообщению

Andrew Stephens

не прочитано,
1 окт. 2014 г., 06:24:1101.10.2014
– rav...@googlegroups.com
I suspect this might be a Json.NET issue, but perhaps someone here can shed some light on it. 

I'm persisting a large object graph to Raven, and several of the classes are marked with the [JsonObject(IsReference = true)] attribute, as they are referenced by other objects elsewhere in the hierarchy. These objects get serialized as expected (i.e. a '$id' value is added to one instance, and duplicate instances are replaced with a '$ref' value).

I recently added a new class to the hierarchy, again marked with the same JsonObject attribute, but it's not being "de-duplicated" like the others. Instances of this class within the graph are definitely the exact same object reference, and there is nothing unusual about the new class compared to the others - it has a parameterless ctr, and is being used in the hierarchy in much the same way.

I can get them de-duplicated using the following code:-

            documentStore.Conventions.CustomizeJsonSerializer = s =>
            {
                s.PreserveReferencesHandling = PreserveReferencesHandling.Objects;
            }; 

But this feels a bit extreme, and I wanted to avoid going down this route if possible.

Unfortunately I wasn't able to create a failing test, probably due to the large and complex nature of the object graph. Any thoughts or suggestions? I'm using Raven 2.5.2750 btw.

Oren Eini (Ayende Rahien)

не прочитано,
1 окт. 2014 г., 11:00:3001.10.2014
– ravendb
That probably deserve to go in the json.net mailing list.
But this configuration is fine for RavenDB.

Hibernating Rhinos Ltd  

Oren Eini l CEO Mobile: + 972-52-548-6969

Office: +972-4-622-7811 l Fax: +972-153-4-622-7811

 


--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ответить всем
Отправить сообщение автору
Переслать
0 новых сообщений