FeedIterator Class

Definition

Cosmos Result set iterator that keeps track of the continuation token when retrieving results form a query.

public abstract class FeedIterator : IDisposable
type FeedIterator = class
    interface IDisposable
Public MustInherit Class FeedIterator
Implements IDisposable
Inheritance
FeedIterator
Implements

Examples

Example on how to fully drain the query results.

QueryDefinition queryDefinition = new QueryDefinition("select c.id From c where c.status = @status")
              .WithParameter("@status", "Failure");
using (FeedIterator feedIterator = this.Container.GetItemQueryStreamIterator(
    queryDefinition))
{
    while (feedIterator.HasMoreResults)
    {
        // Stream iterator returns a response with status code
        using(ResponseMessage response = await feedIterator.ReadNextAsync())
        {
            // Handle failure scenario
            if(!response.IsSuccessStatusCode)
            {
                // Log the response.Diagnostics and handle the error
            }
        }
    }
}

Constructors

FeedIterator()

Properties

HasMoreResults

Tells if there is more results that need to be retrieved from the service

Methods

Dispose()

Releases the unmanaged resources used by the FeedIterator and optionally releases the managed resources.

Dispose(Boolean)

Releases the unmanaged resources used by the FeedIterator and optionally releases the managed resources.

ReadNextAsync(CancellationToken)

Get the next set of results from the cosmos service

Applies to