public IEnumerable <TAggregate> GetAll() { var aggregateType = typeof(TAggregate); if (!AggregateTypeStreams.TryGetValue(aggregateType, out var aggregateStreams)) { throw new KeyNotFoundException($"Aggregates of type {aggregateType.FullName} not stored in this storage."); } return(aggregateStreams.Select(pair => (TAggregate)pair.Value)); }
/// <inheritdoc /> public Task <TAggregate> Read(Guid aggregateId) { var aggregateType = typeof(TAggregate); if (!AggregateTypeStreams.TryGetValue(aggregateType, out var aggregateStreams) || !aggregateStreams.TryGetValue(aggregateId, out var aggregate)) { throw new KeyNotFoundException($"An aggregate of type {aggregateType.FullName} with ID {aggregateId} not found."); } return(Task.FromResult((TAggregate)aggregate)); }