Conventions: Serialization


If you need to modify JsonSerializer object used by the client when sending entities to the server you can register a customization action:

CustomizeJsonSerializer = serializer => throw new CodeOmitted()


To modify the JsonSerializer object used by the client to deserialize entities loaded from the server, you can register a customization action:

CustomizeJsonDeserializer = serializer => throw new CodeOmitted()


In order to customize the entity deserialization from blittable JSON you can use define DeserializeEntityFromBlittable implementation:

DeserializeEntityFromBlittable = (type, blittable) => throw new CodeOmitted()


The default JsonContractResolver used by RavenDB will serialize all properties and all public fields. You can change it by providing own implementation of IContractResolver interface:

JsonContractResolver = new CustomJsonContractResolver()

public class CustomJsonContractResolver : IContractResolver
    public JsonContract ResolveContract(Type type)
        throw new CodeOmitted();

You can also customize behavior of the default resolver by inheriting from DefaultRavenContractResolver and overriding specific methods.

public class CustomizedRavenJsonContractResolver : DefaultRavenContractResolver
    protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization)
        throw new CodeOmitted();


Controls whatever properties that were not de-serialized to an object properties will be preserved during saving a document again. If false, those properties will be removed when the document will be saved. Default: true.

PreserveDocumentPropertiesNotFoundOnModel = true


For the bulk insert you can configure custom serialization implementation by providing TrySerializeEntityToJsonStream:

BulkInsert =
    TrySerializeEntityToJsonStream = (entity, metadata, writer) => throw new CodeOmitted(),

Numbers (de)serialization

RavenDB client supports out of the box all common numeric value types: int, long, double, decimal etc.
Note that although the (de)serialization of decimals is fully supported, there are server side limitations to numbers in that range.
Other number types like BigInteger must be treated using custom (de)serialization.