如何执行Azure表存储查询异步?客户端版本4.0.1 [英] How to execute an Azure table storage query async? client version 4.0.1
本文介绍了如何执行Azure表存储查询异步?客户端版本4.0.1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
要在Azure存储客户端4.0.1版上执行查询异步
Want to execute queries Async on Azure Storage Client Version 4.0.1
没有方法ExecuteQueryAsync().
There is NO method ExecuteQueryAsync()..
我想念什么吗?我们应该继续使用ExecuteQuerySegmentedAsync吗? 谢谢.
I am missing something? Should we continue to use the ExecuteQuerySegmentedAsync still? Thanks.
推荐答案
我最终提出了一种扩展方法以使用ExecuteQuerySegmentedAsync. 我不确定这种解决方案是否是最佳解决方案,如果有人有任何评论,请不要犹豫.
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;
}
这篇关于如何执行Azure表存储查询异步?客户端版本4.0.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文