Load items of different type from collection

Hello guys,

I have a question about type inheritance and casting.

Lets say i have a base type A with two child types A1 and A2.

An object of B has a collection IList<A>, which in turn populated with objects of types A1 and A2. A collection is save into a document an has proper structure.

How could i load a collection of IList<A> with proper list items types (A1 and A2)?


@arkadyb -

The Couchbase .NET SDK uses the JSON.NET serializer to handle all mapping from JSON to your domain model. From a bit of googling it looks like you can create a custom JsonConverter to support this: http://blog.codeinside.eu/2015/03/30/json-dotnet-deserialize-to-abstract-class-or-interface/

Once you have a customized JsonConverter you can set the ClientConfiguration.SerializationSettings and ClientConfiguration.DerializationSettings fields with the it.