public Task <T> Execute <T>(Func <SagaRepositoryContext <TSaga>, Task <T> > asyncMethod, CancellationToken cancellationToken = default)
            where T : class
        {
            var repositoryContext = new DocumentDbSagaRepositoryContext <TSaga>(_context, cancellationToken);

            return(asyncMethod(repositoryContext));
        }
        public Task Send <T>(ConsumeContext <T> context, IPipe <SagaRepositoryContext <TSaga, T> > next)
            where T : class
        {
            var repositoryContext = new DocumentDbSagaRepositoryContext <TSaga, T>(_context, context, _factory);

            return(next.Send(repositoryContext));
        }
        public async Task SendQuery <T>(ConsumeContext <T> context, ISagaQuery <TSaga> query, IPipe <SagaRepositoryQueryContext <TSaga, T> > next)
            where T : class
        {
            // This will not work for Document Db because the .Where needs to look for [JsonProperty("id")],
            // and if you pass in CorrelationId property, the ISaga doesn't have that property. Can we .Select() it out?
            IEnumerable <TSaga> sagas = await _context.Client.CreateDocumentQuery <TSaga>(_context.Collection, _context.FeedOptions)
                                        .Where(query.FilterExpression)
                                        .QueryAsync(context.CancellationToken)
                                        .ConfigureAwait(false);

            var repositoryContext = new DocumentDbSagaRepositoryContext <TSaga, T>(_context, context, _factory);

            var queryContext = new LoadedSagaRepositoryQueryContext <TSaga, T>(repositoryContext, sagas.ToList());

            await next.Send(queryContext).ConfigureAwait(false);
        }