How to execute an Azure table storage query async? client version 4.0.1

后端 未结 3 851
甜味超标
甜味超标 2021-01-30 16:07

Want to execute queries Async on Azure Storage Client Version 4.0.1

There is NO method ExecuteQueryAsync()..

I am missing something? Should we continue to use th

3条回答
  •  感情败类
    2021-01-30 16:21

    I end up making an extension method to use ExecuteQuerySegmentedAsync. I am not sure whether this solution is optimal, if anybody has any comment please don’t hesitate.

    public static async Task> ExecuteQueryAsync(this CloudTable table, TableQuery query, CancellationToken ct = default(CancellationToken), Action> onProgress = null) where T : ITableEntity, new()
        {
    
            var items = new List();
            TableContinuationToken token = null;
    
            do
            {
    
                TableQuerySegment seg = await table.ExecuteQuerySegmentedAsync(query, token);
                token = seg.ContinuationToken;
                items.AddRange(seg);
                if (onProgress != null) onProgress(items);
    
            } while (token != null && !ct.IsCancellationRequested);
    
            return items;
        }
    

提交回复
热议问题