<commit_before>using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using CQRSMagic.Azure.Support;
using CQRSMagic.Domain;
using CQRSMagic.Events.Messaging;
using CQRSMagic.Events.Sourcing.Repositories;
using Microsoft.Practices.ServiceLocation;
using Microsoft.WindowsAzure.Storage.Table;

namespace CQRSMagic.Azure
{
    public class AzureEventStoreRepository : IEventStoreRepository
    {
        private readonly AzureTableRepository<DynamicTableEntity> Repository;
        private readonly IAzureEventSerializer Serializer;

        public AzureEventStoreRepository(string connectionString, string tableName)
            : this(connectionString, tableName, ServiceLocator.Current.GetInstance<IAzureEventSerializer>())
        {
        }

        public AzureEventStoreRepository(string connectionString, string tableName, IAzureEventSerializer serializer)
        {
            Serializer = serializer;
            Repository = new AzureTableRepository<DynamicTableEntity>(connectionString, tableName);
        }

        public IEnumerable<IEvent> GetEvents<TAggregate>(Guid aggregateId) where TAggregate : IAggregate
        {
            var entities = Repository.FindEntitiesByPartitionKeyAsync(aggregateId.ToPartitionKey()).Result;
            var events = entities.Select(Serializer.Deserialize);

            return events;
        }

        public void SaveEvents(IEnumerable<IEvent> events)
        {
            // todo: unit tests
            var entities = events.Select(Serializer.Serialize);
            var tasks = entities.Select(Repository.AddAsync);

            Task.WaitAll(tasks.ToArray());
        }
    }
}<commit_msg>Changed AzureEventStoreRepository.SaveEvents to be debug friendlier.<commit_after>using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using CQRSMagic.Azure.Support;
using CQRSMagic.Domain;
using CQRSMagic.Events.Messaging;
using CQRSMagic.Events.Sourcing.Repositories;
using Microsoft.Practices.ServiceLocation;
using Microsoft.WindowsAzure.Storage.Table;

namespace CQRSMagic.Azure
{
    public class AzureEventStoreRepository : IEventStoreRepository
    {
        private readonly AzureTableRepository<DynamicTableEntity> Repository;
        private readonly IAzureEventSerializer Serializer;

        public AzureEventStoreRepository(string connectionString, string tableName)
            : this(connectionString, tableName, ServiceLocator.Current.GetInstance<IAzureEventSerializer>())
        {
        }

        public AzureEventStoreRepository(string connectionString, string tableName, IAzureEventSerializer serializer)
        {
            Serializer = serializer;
            Repository = new AzureTableRepository<DynamicTableEntity>(connectionString, tableName);
        }

        public IEnumerable<IEvent> GetEvents<TAggregate>(Guid aggregateId) where TAggregate : IAggregate
        {
            var entities = Repository.FindEntitiesByPartitionKeyAsync(aggregateId.ToPartitionKey()).Result;
            var events = entities.Select(Serializer.Deserialize);

            return events;
        }

        public void SaveEvents(IEnumerable<IEvent> events)
        {
            foreach (var @event in events)
            {
                var entity = Serializer.Serialize(@event);

                Repository.AddAsync(entity).Wait();
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.07251461988304093, 'fraction_numerical': 0.0, 'mean_word_length': 3.2655860349127184, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '367889', 'n_tokens_mistral': 872, 'n_tokens_neox': 838, 'n_words': 172}