Example #1
0
 /// <summary>
 /// Try to upload one document.
 /// If the operation fails because document is too large, nothing is changed and "tooLarge" is set true.
 /// If the operation fails due to other reasons, nothing is changed and an exception is thrown
 /// If the operation succeeds, docObject["id"] is set if it doesn't have one
 /// </summary>
 /// <param name="connection"></param>
 /// <param name="docId"></param>
 /// <param name="docObject"></param>
 /// <param name="tooLarge"></param>
 private static void UploadOne(GraphViewConnection connection, string docId, JObject docObject, out bool tooLarge)
 {
     tooLarge = false;
     try {
         connection.ReplaceOrDeleteDocumentAsync(docId, docObject).Wait();
     }
     catch (AggregateException ex) when(ex.InnerException?.GetType().Name.Equals("RequestEntityTooLargeException") ?? false)
     {
         tooLarge = true;
     }
 }
Example #2
0
 /// <summary>
 /// Try to upload one document.
 /// If the operation fails because document is too large, nothing is changed and "tooLarge" is set true.
 /// If the operation fails due to other reasons, nothing is changed and an exception is thrown
 /// If the operation succeeds, docObject["id"] is set if it doesn't have one
 /// </summary>
 /// <param name="connection"></param>
 /// <param name="docId"></param>
 /// <param name="docObject"></param>
 /// <param name="tooLarge"></param>
 private static void UploadOne(GraphViewConnection connection, string docId, JObject docObject, out bool tooLarge)
 {
     tooLarge = false;
     try {
         Debug.Assert(docObject != null);
         connection.ReplaceOrDeleteDocumentAsync(docId, docObject, (string)docObject["_partition"]).Wait();
     }
     catch (AggregateException ex)
         when((ex.InnerException as DocumentClientException)?.Error.Code == "RequestEntityTooLarge")
         {
             tooLarge = true;
         }
 }