Skip to content

Instantly share code, notes, and snippets.

@ankitvijay
Last active June 19, 2021 22:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ankitvijay/a2abe13f411862443b95604bd90a37e0 to your computer and use it in GitHub Desktop.
Save ankitvijay/a2abe13f411862443b95604bd90a37e0 to your computer and use it in GitHub Desktop.
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