Table of Contents

Class FeedIterator<T>

Namespace
Microsoft.Azure.Cosmos
Assembly
Microsoft.Azure.Cosmos.Client.dll

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

public abstract class FeedIterator<T> : IDisposable

Type Parameters

T
Inheritance
FeedIterator<T>
Implements
Inherited Members
Extension Methods

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<MyItem> feedIterator = this.Container.GetItemQueryIterator<MyItem>(
    queryDefinition))
{
    while (feedIterator.HasMoreResults)
    {
        FeedResponse<MyItem> response = await feedIterator.ReadNextAsync();
        foreach (var item in response)
        {
            Console.WriteLine(item);
        }
    }
}

Constructors

FeedIterator()

protected FeedIterator()

Properties

HasMoreResults

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

public abstract bool HasMoreResults { get; }

Property Value

bool

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<MyItem> feedIterator = this.Container.GetItemQueryIterator<MyItem>(
    queryDefinition))
{
    while (feedIterator.HasMoreResults)
    {
        FeedResponse<MyItem> response = await feedIterator.ReadNextAsync();
        foreach (var item in response)
        {
            Console.WriteLine(item);
        }
    }
}

Methods

Dispose()

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

public void Dispose()

Dispose(bool)

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

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

true to release both managed and unmanaged resources; false to release only unmanaged resources.

ReadNextAsync(CancellationToken)

Get the next set of results from the cosmos service

public abstract Task<FeedResponse<T>> ReadNextAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

(Optional) CancellationToken representing request cancellation.

Returns

Task<FeedResponse<T>>

A query response from cosmos service

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<MyItem> feedIterator = this.Container.GetItemQueryIterator<MyItem>(
    queryDefinition))
{
    while (feedIterator.HasMoreResults)
    {
        FeedResponse<MyItem> response = await feedIterator.ReadNextAsync();
        foreach (var item in response)
        {
            Console.WriteLine(item);
        }
    }
}