다음을 통해 공유


CosmosContainer.GetItemQueryStreamIterator Method

Definition

Overloads

GetItemQueryStreamIterator(QueryDefinition, String, QueryRequestOptions, CancellationToken)

This method creates a query for items under a container in an Azure Cosmos database using a SQL statement with parameterized values. It returns a FeedIterator. For more information on preparing SQL statements with parameterized values, please see QueryDefinition.

GetItemQueryStreamIterator(String, String, QueryRequestOptions, CancellationToken)

This method creates a query for items under a container in an Azure Cosmos database using a SQL statement with parameterized values. It returns a FeedIterator. For more information on preparing SQL statements with parameterized values, please see QueryDefinition.

GetItemQueryStreamIterator(QueryDefinition, String, QueryRequestOptions, CancellationToken)

This method creates a query for items under a container in an Azure Cosmos database using a SQL statement with parameterized values. It returns a FeedIterator. For more information on preparing SQL statements with parameterized values, please see QueryDefinition.

public abstract System.Collections.Generic.IAsyncEnumerable<Azure.Response> GetItemQueryStreamIterator (Azure.Cosmos.QueryDefinition queryDefinition, string continuationToken = default, Azure.Cosmos.QueryRequestOptions requestOptions = default, System.Threading.CancellationToken cancellationToken = default);
abstract member GetItemQueryStreamIterator : Azure.Cosmos.QueryDefinition * string * Azure.Cosmos.QueryRequestOptions * System.Threading.CancellationToken -> System.Collections.Generic.IAsyncEnumerable<Azure.Response>
Public MustOverride Function GetItemQueryStreamIterator (queryDefinition As QueryDefinition, Optional continuationToken As String = Nothing, Optional requestOptions As QueryRequestOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As IAsyncEnumerable(Of Response)

Parameters

queryDefinition
QueryDefinition

The cosmos SQL query definition.

continuationToken
String

(Optional) The continuation token in the Azure Cosmos DB service.

requestOptions
QueryRequestOptions

(Optional) The options for the item query request QueryRequestOptions

cancellationToken
CancellationToken

(Optional) CancellationToken representing request cancellation.

Returns

An iterator to go through the items.

Examples

Create a query to get all the ToDoActivity that have a cost greater than 9000 for the specified partition

public class ToDoActivity{
    public string id {get; set;}
    public string status {get; set;}
    public int cost {get; set;}
}

QueryDefinition queryDefinition = new QueryDefinition("select * from ToDos t where t.cost > @expensive")
    .WithParameter("@expensive", 9000);
await foreach(Response response in this.Container.GetItemQueryStreamIterator(
                                                queryDefinition,
                                                null,
                                                new QueryRequestOptions() { PartitionKey = new PartitionKey("Error")}))
    {
        using (StreamReader sr = new StreamReader(response.Content))
        using (JsonTextReader jtr = new JsonTextReader(sr))
        {
            JObject result = JObject.Load(jtr);
        }
    }

Remarks

Query as a stream only supports single partition queries

Applies to

GetItemQueryStreamIterator(String, String, QueryRequestOptions, CancellationToken)

This method creates a query for items under a container in an Azure Cosmos database using a SQL statement with parameterized values. It returns a FeedIterator. For more information on preparing SQL statements with parameterized values, please see QueryDefinition.

public abstract System.Collections.Generic.IAsyncEnumerable<Azure.Response> GetItemQueryStreamIterator (string queryText = default, string continuationToken = default, Azure.Cosmos.QueryRequestOptions requestOptions = default, System.Threading.CancellationToken cancellationToken = default);
abstract member GetItemQueryStreamIterator : string * string * Azure.Cosmos.QueryRequestOptions * System.Threading.CancellationToken -> System.Collections.Generic.IAsyncEnumerable<Azure.Response>
Public MustOverride Function GetItemQueryStreamIterator (Optional queryText As String = Nothing, Optional continuationToken As String = Nothing, Optional requestOptions As QueryRequestOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As IAsyncEnumerable(Of Response)

Parameters

queryText
String

The cosmos SQL query text.

continuationToken
String

(Optional) The continuation token in the Azure Cosmos DB service.

requestOptions
QueryRequestOptions

(Optional) The options for the item query request QueryRequestOptions

cancellationToken
CancellationToken

(Optional) CancellationToken representing request cancellation.

Returns

An iterator to go through the items.

Examples

  1. Create a query to get all the ToDoActivity that have a cost greater than 9000 for the specified partition
public class ToDoActivity{
    public string id {get; set;}
    public string status {get; set;}
    public int cost {get; set;}
}

await foreach(Response response in this.Container.GetItemQueryStreamIterator(
    "select * from ToDos t where t.cost > 9000",
    null,
    new QueryRequestOptions() { PartitionKey = new PartitionKey("Error")}))
{
        using (StreamReader sr = new StreamReader(response.Content))
        using (JsonTextReader jtr = new JsonTextReader(sr))
        {
            JObject result = JObject.Load(jtr);
        }
}

  1. Creates a FeedIterator to get all the ToDoActivity.
public class ToDoActivity{
    public string id {get; set;}
    public string status {get; set;}
    public int cost {get; set;}
}

await foreach(Response response in this.Container.GetItemQueryStreamIterator(
    null,
    null,
    new QueryRequestOptions() { PartitionKey = new PartitionKey("Error")}))
{
        using (StreamReader sr = new StreamReader(response.Content))
        using (JsonTextReader jtr = new JsonTextReader(sr))
        {
            JObject result = JObject.Load(jtr);
        }
}

Remarks

Query as a stream only supports single partition queries

Applies to