Database.GetContainerQueryStreamIterator メソッド

定義

オーバーロード

GetContainerQueryStreamIterator(QueryDefinition, String, QueryRequestOptions)

このメソッドは、パラメーター化された値を持つ SQL ステートメントを使用して、データベースの下にコンテナーのクエリを作成します。 FeedIterator を返します。 パラメーター化された値を使用した SQL ステートメントの準備の詳細については、「オーバーロード」を参照してください QueryDefinition

GetContainerQueryStreamIterator(String, String, QueryRequestOptions)

このメソッドは、SQL ステートメントを使用して、データベースの下にコンテナーのクエリを作成します。 FeedIterator を返します。

GetContainerQueryStreamIterator(QueryDefinition, String, QueryRequestOptions)

ソース:
Database.cs

このメソッドは、パラメーター化された値を持つ SQL ステートメントを使用して、データベースの下にコンテナーのクエリを作成します。 FeedIterator を返します。 パラメーター化された値を使用した SQL ステートメントの準備の詳細については、「オーバーロード」を参照してください QueryDefinition

public abstract Microsoft.Azure.Cosmos.FeedIterator GetContainerQueryStreamIterator (Microsoft.Azure.Cosmos.QueryDefinition queryDefinition, string continuationToken = default, Microsoft.Azure.Cosmos.QueryRequestOptions requestOptions = default);
abstract member GetContainerQueryStreamIterator : Microsoft.Azure.Cosmos.QueryDefinition * string * Microsoft.Azure.Cosmos.QueryRequestOptions -> Microsoft.Azure.Cosmos.FeedIterator
Public MustOverride Function GetContainerQueryStreamIterator (queryDefinition As QueryDefinition, Optional continuationToken As String = Nothing, Optional requestOptions As QueryRequestOptions = Nothing) As FeedIterator

パラメーター

queryDefinition
QueryDefinition

Cosmos SQL クエリ定義。

continuationToken
String

Azure Cosmos DB サービスの継続トークン。

requestOptions
QueryRequestOptions

(省略可能)コンテナー要求のオプション。

戻り値

コンテナーを通過する反復子

これにより、queryDefinition を入力として持つコンテナーのストリーム フィード反復子が作成されます。

string queryText = "SELECT c.id FROM c where c.status like 'start%'";
QueryDefinition queryDefinition = new QueryDefinition(queryText);
using (FeedIterator feedIterator = this.cosmosDatabase.GetContainerQueryStreamIterator(queryDefinition))
{
    while (feedIterator.HasMoreResults)
    {
        using (ResponseMessage response = await feedIterator.ReadNextAsync())
        {
            response.EnsureSuccessStatusCode();
            using (StreamReader sr = new StreamReader(response.Content))
            using (JsonTextReader jtr = new JsonTextReader(sr))
            {
                // The stream content contains the following JSON structure
                // {"_rid":"FwsdAA==","DocumentCollections":[{"id":"container1"},{"id":"container2"}],"_count":2}
                JObject result = JObject.Load(jtr);
            }
        }
    }
}

これにより、すべてのコンテナー ID の一覧を取得するフィード反復子が作成されます

using (FeedIterator feedIterator = this.cosmosDatabase.GetContainerQueryStreamIterator(
      new QueryDefinition("select value c.id From c ")))
  {
      while (feedIterator.HasMoreResults)
      {
          using (ResponseMessage response = await feedIterator.ReadNextAsync())
          {
               response.EnsureSuccessStatusCode();
               using (StreamReader streamReader = new StreamReader(response.Content))
               using (JsonTextReader jsonTextReader = new JsonTextReader(streamReader))
               {
                    // The stream content contains the following JSON structure
                    // {"_rid":"7p8wAA==","DocumentCollections":["container1","container2"],"_count":2}
                    JObject jObject = await JObject.LoadAsync(jsonTextReader);
                }
        }
    }
}

注釈

構文と例については、 を https://docs.microsoft.com/azure/cosmos-db/sql-query-getting-started 参照してください。

ReadContainerStreamAsync(ContainerRequestOptions, CancellationToken) は、単一コンテナーの検索に推奨されます。

適用対象

GetContainerQueryStreamIterator(String, String, QueryRequestOptions)

ソース:
Database.cs

このメソッドは、SQL ステートメントを使用して、データベースの下にコンテナーのクエリを作成します。 FeedIterator を返します。

public abstract Microsoft.Azure.Cosmos.FeedIterator GetContainerQueryStreamIterator (string queryText = default, string continuationToken = default, Microsoft.Azure.Cosmos.QueryRequestOptions requestOptions = default);
abstract member GetContainerQueryStreamIterator : string * string * Microsoft.Azure.Cosmos.QueryRequestOptions -> Microsoft.Azure.Cosmos.FeedIterator
Public MustOverride Function GetContainerQueryStreamIterator (Optional queryText As String = Nothing, Optional continuationToken As String = Nothing, Optional requestOptions As QueryRequestOptions = Nothing) As FeedIterator

パラメーター

queryText
String

Cosmos SQL クエリ テキスト。

continuationToken
String

Azure Cosmos DB サービスの継続トークン。

requestOptions
QueryRequestOptions

(省略可能)コンテナー要求のオプション。

戻り値

コンテナーを通過する反復子

これにより、queryDefinition を入力として持つコンテナーのストリーム フィード反復子が作成されます。

using (FeedIterator feedIterator = this.cosmosDatabase.GetContainerQueryStreamIterator(
    "SELECT c.id FROM c where c.status like 'start%'"))
{
    while (feedIterator.HasMoreResults)
    {
        using (ResponseMessage response = await feedIterator.ReadNextAsync())
        {
            response.EnsureSuccessStatusCode();
            using (StreamReader sr = new StreamReader(response.Content))
            using (JsonTextReader jtr = new JsonTextReader(sr))
            {
                // The stream content contains the following JSON structure
                // {"_rid":"FwsdAA==","DocumentCollections":[{"id":"container1"},{"id":"container2"}],"_count":2}
                JObject result = JObject.Load(jtr);
            }
        }
    }
}

これにより、すべてのコンテナー ID の一覧を取得するフィード反復子が作成されます

using (FeedIterator feedIterator = this.cosmosDatabase.GetContainerQueryStreamIterator(
      "select value c.id From c "))
  {
      while (feedIterator.HasMoreResults)
      {
          using (ResponseMessage response = await feedIterator.ReadNextAsync())
          {
               response.EnsureSuccessStatusCode();
               using (StreamReader streamReader = new StreamReader(response.Content))
               using (JsonTextReader jsonTextReader = new JsonTextReader(streamReader))
               {
                    // The stream content contains the following JSON structure
                    // {"_rid":"7p8wAA==","DocumentCollections":["container1","container2"],"_count":2}
                    JObject jObject = await JObject.LoadAsync(jsonTextReader);
                }
        }
    }
}

注釈

構文と例については、 を https://docs.microsoft.com/azure/cosmos-db/sql-query-getting-started 参照してください。

ReadContainerStreamAsync(ContainerRequestOptions, CancellationToken) は、単一コンテナーの検索に推奨されます。

適用対象