Redigera

Dela via


IDocumentWriter<TDocument>.ReplaceDocumentAsync Method

Definition

Replaces a document having provided id with Document.

public:
 System::Threading::Tasks::Task<System::Cloud::DocumentDb::IDatabaseResponse<TDocument> ^> ^ ReplaceDocumentAsync(System::Cloud::DocumentDb::RequestOptions<TDocument> ^ options, System::String ^ id, System::Threading::CancellationToken cancellationToken);
public System.Threading.Tasks.Task<System.Cloud.DocumentDb.IDatabaseResponse<TDocument>> ReplaceDocumentAsync(System.Cloud.DocumentDb.RequestOptions<TDocument> options, string id, System.Threading.CancellationToken cancellationToken);
abstract member ReplaceDocumentAsync : System.Cloud.DocumentDb.RequestOptions<'Document> * string * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Cloud.DocumentDb.IDatabaseResponse<'Document>>
Public Function ReplaceDocumentAsync (options As RequestOptions(Of TDocument), id As String, cancellationToken As CancellationToken) As Task(Of IDatabaseResponse(Of TDocument))

Parameters

options
RequestOptions<TDocument>

The request options.

id
String

Id of the document to replace.

cancellationToken
CancellationToken

The token represents request cancellation.

Returns

Task<IDatabaseResponse<TDocument>>

A Task containing a IDatabaseResponse<T> that wraps the updated document.

Exceptions

Thrown when an error occurred on a client side. For example on a bad request, permissions error or client timeout.

Thrown when an error occurred on a database server side, including internal server error.

Thrown when a request failed but can be retried. This includes throttling and server not available cases.

A generic exception thrown in all other not covered above cases.

Remarks

The request will fail if a document having the provided id does not exist. If the id in the document different from the id provided in Document, the id will be updated too. After the operation succeed there will be no document with the old id anymore.

Applies to