/// <summary> /// Partially updates the document identified by document-handle. /// The body of the request must contain a JSON document with the /// attributes to patch(the patch document). All attributes from the /// patch document will be added to the existing document if they do not /// yet exist, and overwritten in the existing document if they do exist /// there. /// PATCH/_api/document/{document-handle} /// </summary> /// <typeparam name="TPatch">Type of the patch object used to partially update a document.</typeparam> /// <typeparam name="TResponse">Type of the returned document, only applies when /// <see cref="PatchDocumentOptions.ReturnNew"/> or <see cref="PatchDocumentOptions.ReturnOld"/> /// are used.</typeparam> /// <param name="documentId"></param> /// <param name="body"></param> /// <param name="query"></param> /// <returns></returns> public virtual async Task <PatchDocumentResponse <TResponse> > PatchDocumentAsync <TPatch, TResponse>( string documentId, TPatch body, PatchDocumentOptions query = null, CancellationToken cancellationToken = default) { ValidateDocumentId(documentId); return(await PatchRequestAsync(ApiRootPath + "/" + documentId, response => new PatchDocumentResponse <TResponse>(response), body, query, cancellationToken)); }
/// <summary> /// Partially updates the document identified by document-handle. /// The body of the request must contain a JSON document with the /// attributes to patch(the patch document). All attributes from the /// patch document will be added to the existing document if they do not /// yet exist, and overwritten in the existing document if they do exist /// there. /// PATCH/_api/document/{document-handle} /// </summary> /// <typeparam name="T">Type of the patch object used to partially update a document.</typeparam> /// <typeparam name="TResponse">Type of the returned document, only applies when /// <see cref="PatchDocumentOptions.ReturnNew"/> or <see cref="PatchDocumentOptions.ReturnOld"/> /// are used.</typeparam> /// <param name="collectionName"></param> /// <param name="documentKey"></param> /// <param name="body"></param> /// <param name="query"></param> /// <returns></returns> public virtual async Task <PatchDocumentResponse <TResponse> > PatchDocumentAsync <TPatch, TResponse>( string collectionName, string documentKey, TPatch body, PatchDocumentOptions query = null, CancellationToken cancellationToken = default) { string documentHandle = WebUtility.UrlEncode(collectionName) + "/" + WebUtility.UrlEncode(documentKey); return(await PatchDocumentAsync <TPatch, TResponse>(documentHandle, body, query, cancellationToken)); }