I want to save object type as a part of json object when upsert my object into cosmos db. I've tried to pass a json serializer when instantiating instance of Cosmos Client, but it doesn't work. I still don't see type of object in document. What I was trying to do:
public static readonly JsonSerializerSettings DefaultJsonSerializerSettings =
new JsonSerializerSettings
{
TypeNameHandling = TypeNameHandling.All,
DateFormatString = "o",
DateFormatHandling = DateFormatHandling.IsoDateFormat,
};
var CosmosClient =
new DocumentClient(
new Uri(CosmosConfig.ServiceEndpoint),
CosmosConfig.AuthNKey,
DefaultJsonSerializerSettings,
connectionPolicySettings);
Any other way to have such a behavior without preprocessing (converting object to jObject) first? Thanks
Upd:
What I trying to achive is smth like next structure in my document (automaticaly serialized type):
{
"$type" : "MyNamespace.Foo",
"Id": "1560e1be-bf87-4720-a22e-b7e2c4c37f2e",
"Name" : "Vasia"
}
instead of current one like this (without type):
{
"Id": "1560e1be-bf87-4720-a22e-b7e2c4c37f2e",
"Name" : "Vasia"
}