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

            return(await asyncMethod(repositoryContext).ConfigureAwait(false));
        }
        public async Task Send <T>(ConsumeContext <T> context, IPipe <SagaRepositoryContext <TSaga, T> > next)
            where T : class
        {
            var repositoryContext = new MongoDbSagaRepositoryContext <TSaga, T>(_mongoCollection, context, _factory);

            await next.Send(repositoryContext).ConfigureAwait(false);
        }
        public async Task SendQuery <T>(ConsumeContext <T> context, ISagaQuery <TSaga> query, IPipe <SagaRepositoryQueryContext <TSaga, T> > next)
            where T : class
        {
            var repositoryContext = new MongoDbSagaRepositoryContext <TSaga, T>(_mongoCollection, context, _factory);

            IList <TSaga> instances = await _mongoCollection.Find(query.FilterExpression)
                                      .ToListAsync(repositoryContext.CancellationToken)
                                      .ConfigureAwait(false);

            var queryContext = new LoadedSagaRepositoryQueryContext <TSaga, T>(repositoryContext, instances);

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