问题描述
你好
是否有一种直接从服务读取而不是使用MoveNextAsync进行迭代的方法.
Is there a way out to read directly from service instead of iterate using MoveNextAsync.
处理时间很长> 50000条记录.
It is taking long time to process > 50000 records.
使用(var tx = StateManager.CreateTransaction())
{
var queue =等待StateManager.GetOrAddAsync< IReliableDictionary< Guid,T>>>(_ cacheName);
var items = await queue.CreateEnumerableAsync(tx);
使用(var asyncEnumerator = items.GetAsyncEnumerator())
{
一会儿(等待asyncEnumerator.MoveNextAsync(CancellationToken.None))
{
如果(asyncEnumerator.Current.Key.ToString().StartsWith(startWithKey))
itemList.Add(asyncEnumerator.Current.Value);
}
}
返回itemList;
}
{
var queue = await StateManager.GetOrAddAsync<IReliableDictionary<Guid, T>>(_cacheName);
var items = await queue.CreateEnumerableAsync(tx);
using (var asyncEnumerator = items.GetAsyncEnumerator())
{
while (await asyncEnumerator.MoveNextAsync(CancellationToken.None))
{
if (asyncEnumerator.Current.Key.ToString().StartsWith(startWithKey))
itemList.Add(asyncEnumerator.Current.Value);
}
}
return itemList;
}
Ajay
推荐答案
是花了这么长时间还是新的东西?
Has it always taken this long or is this something new?
这篇关于有状态服务:可靠的字典:GET调用:asyncEnumerator.MoveNextAsync的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!