public static async Task DeleteEventsAsync <TSaga>(this IDynamoDBContext context, TSaga instance, DynamoDbEventStoreOptions options) where TSaga : class, IV2EventSourcedSaga
        {
            var events = await context.GetEventsAsync(instance.CorrelationId, options);

            var writer = context.CreateBatchWrite <V2EventStoreModel>(new DynamoDBOperationConfig {
                OverrideTableName = options.StoreName
            });

            writer.AddDeleteItems(events);

            await writer.ExecuteAsync();
        }
        public static async Task <AggregatedEvents> LoadEventsAsync(this IDynamoDBContext context, Guid aggregateId, IEnumerable <Type> knownTypes, DynamoDbEventStoreOptions options)
        {
            var data = await context.GetEventsAsync(aggregateId, options);

            var events = new List <object>();

            if (data is null)
            {
                return new AggregatedEvents {
                           Events = events, LastVersion = null
                }
            }
            ;

            events.AddRange(data.SelectMany(@event => JsonSerialization.Deserialize(@event, knownTypes)));
            return(new AggregatedEvents {
                Events = events, LastVersion = data.Max(model => model.Version), AggregateId = aggregateId.ToString()
            });
        }