Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 735
Jose Ch. Avatar asked Jun 15 '14 21:06

Jose Ch.


1 Answers

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<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;     } 
like image 91
Jose Ch. Avatar answered Oct 02 '22 07:10

Jose Ch.