Condividi tramite


IDocumentClient.CreateDocumentChangeFeedQuery Method

Definition

Overloads

CreateDocumentChangeFeedQuery(String, ChangeFeedOptions)

Overloaded. This method creates a change feed query for documents under a collection in an Azure Cosmos DB service.

CreateDocumentChangeFeedQuery(Uri, ChangeFeedOptions)

Extension method to create a change feed query for documents in the Azure Cosmos DB service.

CreateDocumentChangeFeedQuery(String, ChangeFeedOptions)

Overloaded. This method creates a change feed query for documents under a collection in an Azure Cosmos DB service.

public Microsoft.Azure.Documents.Linq.IDocumentQuery<Microsoft.Azure.Documents.Document> CreateDocumentChangeFeedQuery (string collectionLink, Microsoft.Azure.Documents.Client.ChangeFeedOptions feedOptions);
abstract member CreateDocumentChangeFeedQuery : string * Microsoft.Azure.Documents.Client.ChangeFeedOptions -> Microsoft.Azure.Documents.Linq.IDocumentQuery<Microsoft.Azure.Documents.Document>
Public Function CreateDocumentChangeFeedQuery (collectionLink As String, feedOptions As ChangeFeedOptions) As IDocumentQuery(Of Document)

Parameters

collectionLink
String

Specifies the collection to read documents from.

feedOptions
ChangeFeedOptions

The options for processing the query results feed.

Returns

the query result set.

Examples

string partitionKeyRangeId = "0";   // Use client.ReadPartitionKeyRangeFeedAsync() to obtain the ranges.
string checkpointContinuation = null;
ChangeFeedOptions options = new ChangeFeedOptions
{
    PartitionKeyRangeId = partitionKeyRangeId,
    RequestContinuation = checkpointContinuation,
    StartFromBeginning = true,
};
using(var query = client.CreateDocumentChangeFeedQuery(collection.SelfLink, options))
{
    while (true)
    {
        do
        {
            var response = await query.ExecuteNextAsync<Document>();
            if (response.Count > 0)
            {
                var docs = new List<Document>();
                docs.AddRange(response);
                // Process the documents.
                // Checkpoint response.ResponseContinuation.
            }
        }
        while (query.HasMoreResults);
        Task.Delay(TimeSpan.FromMilliseconds(500)); // Or break here and use checkpointed continuation token later.
    }       
}

Remarks

ChangeFeedOptions.PartitionKeyRangeId must be provided.

See also

Applies to

CreateDocumentChangeFeedQuery(Uri, ChangeFeedOptions)

Extension method to create a change feed query for documents in the Azure Cosmos DB service.

public Microsoft.Azure.Documents.Linq.IDocumentQuery<Microsoft.Azure.Documents.Document> CreateDocumentChangeFeedQuery (Uri collectionLink, Microsoft.Azure.Documents.Client.ChangeFeedOptions feedOptions);
abstract member CreateDocumentChangeFeedQuery : Uri * Microsoft.Azure.Documents.Client.ChangeFeedOptions -> Microsoft.Azure.Documents.Linq.IDocumentQuery<Microsoft.Azure.Documents.Document>
Public Function CreateDocumentChangeFeedQuery (collectionLink As Uri, feedOptions As ChangeFeedOptions) As IDocumentQuery(Of Document)

Parameters

collectionLink
Uri

Specifies the collection to read documents from.

feedOptions
ChangeFeedOptions

The options for processing the query results feed.

Returns

the query result set.

Applies to