Table of Contents

Class DocumentResponse<TDocument>

Namespace
Microsoft.Azure.Documents.Client
Assembly
Microsoft.Azure.Documents.Client.dll

Represents the template class used by methods returning single objects in the Azure Cosmos DB service.

public sealed class DocumentResponse<TDocument> : ResourceResponseBase, IDocumentResponse<TDocument>, IResourceResponseBase

Type Parameters

TDocument

the document type.

Inheritance
DocumentResponse<TDocument>
Implements
Inherited Members
Extension Methods

Examples

The following example extracts the CustomerName property, request units consumed, activity ID and StatusCode from a ReadDocumentAsync{Customer} call.

DocumentResponse<Customer> response = await client.ReadDocumentAsync<Customer>(documentLink);
Console.WriteLine(response.Document.CustomerName);
Console.WriteLine(response.RequestCharge);
Console.WriteLine(response.ActivityId); 
Console.WriteLine(response.StatusCode); // HttpStatusCode.Created or 201

Remarks

Response from type-specific read of Document resource(ReadDocumentAsync{TDocument}) returns the response wrapped in a DocumentResponse object. This contains the metadata from the response headers from the Azure Cosmos DB call including the request units (RequestCharge), activity ID, quotas/usage of resources and the typed document object(TDocument).

Constructors

DocumentResponse()

Constructor exposed for mocking purposes for the Azure Cosmos DB service.

public DocumentResponse()

DocumentResponse(TDocument)

Constructor exposed for mocking purposes for the Azure Cosmos DB service.

public DocumentResponse(TDocument document)

Parameters

document TDocument

Properties

Document

Gets the document returned in the response from the Azure Cosmos DB service.

public TDocument Document { get; }

Property Value

TDocument

The document returned in the response.

Operators

implicit operator TDocument(DocumentResponse<TDocument>)

Returns the document in the response implicitly from the Azure Cosmos DB service.

public static implicit operator TDocument(DocumentResponse<TDocument> source)

Parameters

source DocumentResponse<TDocument>

The DocumentResponse source.

Returns

TDocument

The document object.