/// <inheritdoc/> public IEnumerable <EventAndEnvelope> GetFor(IApplicationResourceIdentifier eventSource, EventSourceId eventSourceId) { var partitionKeyFilter = GetPartitionKeyFilterFor(eventSource, eventSourceId); var query = new TableQuery <DynamicTableEntity>().Where(partitionKeyFilter); var events = new List <DynamicTableEntity>(); TableContinuationToken continuationToken = null; do { _table.ExecuteQuerySegmentedAsync(query, continuationToken).ContinueWith(e => { events.AddRange(e.Result.Results); continuationToken = e.Result.ContinuationToken; }).Wait(); } while (continuationToken != null); var eventsAndEnvelopes = events.OrderBy(e => long.Parse(e.RowKey)).Select(entity => { var eventResource = GetApplicationResourceIdentifierFromSanitizedString(entity.Properties[PropertiesFor <EventEnvelope> .GetPropertyName(e => e.Event)].StringValue); var eventSourceResource = GetApplicationResourceIdentifierFromSanitizedString(entity.Properties[PropertiesFor <EventEnvelope> .GetPropertyName(e => e.EventSource)].StringValue); var envelope = new EventEnvelope( PropertiesFor <EventEnvelope> .GetValue(entity, e => e.CorrelationId), PropertiesFor <EventEnvelope> .GetValue(entity, e => e.EventId), PropertiesFor <EventEnvelope> .GetValue(entity, e => e.SequenceNumber), PropertiesFor <EventEnvelope> .GetValue(entity, e => e.SequenceNumberForEventType), PropertiesFor <EventEnvelope> .GetValue(entity, e => e.Generation), eventResource, PropertiesFor <EventEnvelope> .GetValue(entity, e => e.EventSourceId), eventSourceResource, PropertiesFor <EventEnvelope> .GetValue(entity, e => e.Version), PropertiesFor <EventEnvelope> .GetValue(entity, e => e.CausedBy), PropertiesFor <EventEnvelope> .GetValue(entity, e => e.Occurred) ); var eventType = _applicationResourceResolver.Resolve(envelope.Event); var @event = Activator.CreateInstance(eventType, envelope.EventSourceId) as IEvent; eventType.GetProperties().Where(p => p.CanWrite).ForEach(p => p.SetValue(@event, PropertyHelper.GetValue(entity, p))); return(new EventAndEnvelope(envelope, @event)); }); return(eventsAndEnvelopes); }