Back
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 the ExecuteQuerySegmentedAsync still? Thanks.
Make an extension as shown below:
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; }
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;
}
31k questions
32.8k answers
501 comments
693 users