次の方法で共有


DigitalTwinsClient.QueryAsync<T>(String, CancellationToken) メソッド

定義

コレクションを非同期的に反復処理して、デジタル ツインのクエリを実行します。

public virtual Azure.AsyncPageable<T> QueryAsync<T> (string query, System.Threading.CancellationToken cancellationToken = default);
abstract member QueryAsync : string * System.Threading.CancellationToken -> Azure.AsyncPageable<'T>
override this.QueryAsync : string * System.Threading.CancellationToken -> Azure.AsyncPageable<'T>
Public Overridable Function QueryAsync(Of T) (query As String, Optional cancellationToken As CancellationToken = Nothing) As AsyncPageable(Of T)

型パラメーター

T

結果を逆シリアル化する型。

パラメーター

query
String

SQL に似た構文のクエリ文字列。

cancellationToken
CancellationToken

キャンセル トークン。

戻り値

クエリ結果のページング可能な一覧 AsyncPageable<T>

例外

サービスからエラーをキャプチャする例外。 詳細については、 ErrorCode プロパティと Status プロパティを確認してください。

// This code snippet demonstrates the simplest way to iterate over the digital twin results, where paging
// happens under the covers.
AsyncPageable<BasicDigitalTwin> asyncPageableResponse = client.QueryAsync<BasicDigitalTwin>("SELECT * FROM digitaltwins");

// Iterate over the twin instances in the pageable response.
// The "await" keyword here is required because new pages will be fetched when necessary,
// which involves a request to the service.
await foreach (BasicDigitalTwin twin in asyncPageableResponse)
{
    Console.WriteLine($"Found digital twin '{twin.Id}'");
}

注釈

その他のサンプルについては、 リポジトリのサンプルを参照してください。 インスタンスの変更がクエリに反映されるまでに遅延が発生する可能性があることに注意してください。 クエリの制限の詳細については、「クエリの 制限事項」を参照してください。

適用対象

こちらもご覧ください