Skip to content

Instantly share code, notes, and snippets.

@ankitvijay
Last active Jun 19, 2021
Embed
What would you like to do?
CosmosClient with Custom Newtonsoft Serializer
var cosmosClient = new CosmosClient("<cosmosDBConnectionString>",
new CosmosClientOptions
{
Serializer = new CosmosJsonDotNetSerializer(new JsonSerializerSettings
{
// Update your JSON Serializer Settings here.
TypeNameHandling = TypeNameHandling.Auto,
ReferenceLoopHandling = ReferenceLoopHandling.Error,
PreserveReferencesHandling = PreserveReferencesHandling.None,
ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor
Converters = new JsonConverter[]
{
new StringEnumConverter()
}
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment