public async Task <long> GetEventsAsync(string actorName, long indexStart, long indexEnd, Action <object> callback) { var config = new QueryOperationConfig { ConsistentRead = true }; config.Filter.AddCondition(_options.EventsTableHashKey, QueryOperator.Equal, actorName); config.Filter.AddCondition(_options.EventsTableSortKey, QueryOperator.Between, indexStart, indexEnd); var query = _eventsTable.Query(config); var lastIndex = -1L; while (true) { var results = await query.GetNextSetAsync(); foreach (var doc in results) { callback(GetData(doc)); lastIndex++; } if (query.IsDone) { break; } } return(lastIndex); object GetData(Document doc) { var dataTypeE = doc.GetValueOrThrow(_options.EventsTableDataTypeKey); var dataE = doc.GetValueOrThrow(_options.EventsTableDataKey); var dataType = Type.GetType(dataTypeE.AsString()); return(_dynamoDBContext.FromDocumentDynamic(dataE.AsDocument(), dataType)); } }