Azure テーブル ストレージ クエリを非同期で実行する方法 クライアント バージョン 4.0.1 質問する

Azure テーブル ストレージ クエリを非同期で実行する方法 クライアント バージョン 4.0.1 質問する

Azure Storage クライアント バージョン 4.0.1 でクエリを非同期に実行したい

ExecuteQueryAsync() メソッドはありません。

何かが足りないのでしょうか? ExecuteQuerySegmentedAsync を引き続き使用すべきでしょうか? ありがとうございます。

ベストアンサー1

最終的には、ExecuteQuerySegmentedAsync を使用するための拡張メソッドを作成します。このソリューションが最適かどうかはわかりませんが、コメントがあれば遠慮なくお寄せください。

public static async Task<IList<T>> ExecuteQueryAsync<T>(this CloudTable table, TableQuery<T> query, CancellationToken ct = default(CancellationToken), Action<IList<T>> onProgress = null) where T : ITableEntity, new()
    {

        var items = new List<T>();
        TableContinuationToken token = null;

        do
        {

            TableQuerySegment<T> seg = await table.ExecuteQuerySegmentedAsync<T>(query, token);
            token = seg.ContinuationToken;
            items.AddRange(seg);
            if (onProgress != null) onProgress(items);

        } while (token != null && !ct.IsCancellationRequested);

        return items;
    }

おすすめ記事