title: How to update cosmos db document using c#
body: <p>I want to update document in cosmos DB if the file name already exists. For that, I passed a query which will bring result and I want to update that result. I want to set the modified date to it. If it's new creating one if it is already there add the modified date to it.<br>
  I am facing the problem updating it which will come in else part.<br>
  Here is my code snippet:</p>
  
  <pre><code>        Class1 obj = new Class1()
          {
              BlobPath = "/container",
              size = (int)myBlob.Length,
              Name = name,
              CreationDateTime = DateTime.Now.ToString()
  
          };
          string obj1 = JsonConvert.SerializeObject(obj);
  
          var query = client.CreateDocumentQuery&lt;Class1&gt;(
              UriFactory.CreateDocumentCollectionUri("testDb", "testDocumentCollection"))
             .Where(jo =&gt; jo.Name.Equals(name))
              .AsEnumerable().FirstOrDefault();
  
  
          if (query == null)
          {
  
              var document1 = await client.CreateDocumentAsync(
                              UriFactory.CreateDocumentCollectionUri("testDb", "testDocumentCollection"),
                              obj);
  
          }
  </code></pre>