private IRecordedEvent Transform(ReactiveEventEntity entity) { return(new RecordedEvent( entity.EventNumber, entity.EventId, entity.EventType, entity.AggregateId, entity.AggregateType, entity.AggregateVersion, _serializer.Deserialize(entity.SerializedData, _typeMapper.GetEventType(entity.EventType)) as IEvent, _serializer.Deserialize(entity.SerializedMetadata, _typeMapper.GetMetadataType(entity.EventType)) as IMetadata, DateTimeOffset.Parse(entity.Recorded) )); }
private IEnumerable <IRecordedEvent <TEvent, TState> > QueryEvents <TEvent, TState>(string query) where TEvent : IEvent <TState> { using (var connection = new SqlConnection(_options.ConnectionString)) { var command = new SqlCommand(query, connection); connection.Open(); var reader = command.ExecuteReader(); while (reader.Read()) { var eventNumber = reader.GetInt64(0); var eventId = reader.GetGuid(1); var eventType = reader.GetString(2); var aggregateId = reader.GetGuid(3); var aggregateType = reader.GetString(4); var aggregateVersion = reader.GetInt64(5); var serializedData = reader.GetString(6); var serializedMetadata = reader.GetString(7); var recorded = reader.GetDateTimeOffset(8); yield return(new RecordedEvent <TEvent, TState>( eventNumber, eventId, eventType, aggregateId, aggregateType, aggregateVersion, _serializer.Deserialize <TEvent>(serializedData), _serializer.Deserialize(serializedMetadata, _typeMapper.GetMetadataType(eventType)) as IMetadata, recorded )); } } }
private IEnumerable <IRecordedEvent> Transform(IEnumerable <RecordedEventEntity> entities) { foreach (var entity in entities) { yield return(new RecordedEvent( entity.EventNumber, entity.EventId, entity.EventType, entity.AggregateId, entity.AggregateType, entity.AggregateVersion, _eventSerializer.Deserialize(entity.SerializedData, _typeMapper.GetEventType(entity.EventType)) as IEvent, _eventSerializer.Deserialize(entity.SerializedMetadata, _typeMapper.GetMetadataType(entity.EventType)) as IMetadata, entity.Recorded )); } }