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
When table query contains take clause specified solution will return more items than requested by query. Small change of while expression will solve that problem.
public static async Task> ExecuteQueryAsync(this CloudTable table, TableQuery query, CancellationToken ct = default(CancellationToken), Action> onProgress = null) where T : ITableEntity, new()
{
var runningQuery = new TableQuery()
{
FilterString = query.FilterString,
SelectColumns = query.SelectColumns
};
var items = new List();
TableContinuationToken token = null;
do
{
runningQuery.TakeCount = query.TakeCount - items.Count;
TableQuerySegment seg = await table.ExecuteQuerySegmentedAsync(runningQuery, token);
token = seg.ContinuationToken;
items.AddRange(seg);
if (onProgress != null) onProgress(items);
} while (token != null && !ct.IsCancellationRequested && (query.TakeCount == null || items.Count < query.TakeCount.Value));
return items;
}
EDITED: Thanks to a suggestion from PaulG, corrected the issue with result count when query contains take clause and ExecuteQuerySegmentedAsync returns items in several passes.