title: Cosmos DB: save object type as a property in document
body: <p>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:</p>
  
  <pre><code>    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);
  </code></pre>
  
  <p>Any other way to have such a behavior without preprocessing (converting object to jObject) first?
  Thanks</p>
  
  <p><strong><em>Upd:</em></strong></p>
  
  <p>What I trying to achive is smth like next structure in my document (automaticaly serialized type):</p>
  
  <pre><code>    {
        "$type" : "MyNamespace.Foo",
        "Id": "1560e1be-bf87-4720-a22e-b7e2c4c37f2e",
        "Name" : "Vasia"
      }
  </code></pre>
  
  <p>instead of current one like this (without type): </p>
  
  <pre><code>    {
        "Id": "1560e1be-bf87-4720-a22e-b7e2c4c37f2e",
        "Name" : "Vasia"
      }
  </code></pre>