Leon V
Leon V

Reputation: 631

Deserializing LocalDate from RavenDB to object

I need to persist LocalDate (from NodaTime) in RavenDB. The object it's represented by is IDictionary<string, object>. Saving works fine (with a little help from https://github.com/ryanheath/RavenDB-NodaTime), but loading returns string. Is there a way to get LocalDate (boxed into object, obviously) on loading?

Upvotes: 1

Views: 36

Answers (1)

garay
garay

Reputation: 666

You would need to customize the JsonSerializer and add a new converter for this.

You can take a look on following examples:

https://github.com/ravendb/ravendb/blob/v4.2/test/SlowTests/Issues/RavenDB_12194.cs#L22

https://ravendb.net/docs/article-page/4.2/csharp/client-api/configuration/serialization#conventions-serialization

Upvotes: 2

Related Questions