Ejemplo n.º 1
0
        public async Task Send <T>(ConsumeContext <T> context, IPipe <SagaRepositoryContext <TSaga, T> > next)
            where T : class
        {
            using DapperDatabaseContext <TSaga> databaseContext = await CreateDatabaseContext(context.CancellationToken).ConfigureAwait(false);

            var repositoryContext = new DapperSagaRepositoryContext <TSaga, T>(databaseContext, context, _factory);

            await next.Send(repositoryContext).ConfigureAwait(false);

            databaseContext.Commit();
        }
Ejemplo n.º 2
0
        public async Task <T> Execute <T>(Func <SagaRepositoryContext <TSaga>, Task <T> > asyncMethod, CancellationToken cancellationToken = default)
            where T : class
        {
            using DapperDatabaseContext <TSaga> databaseContext = await CreateDatabaseContext(cancellationToken).ConfigureAwait(false);

            var sagaRepositoryContext = new DapperSagaRepositoryContext <TSaga>(databaseContext, cancellationToken);

            var result = await asyncMethod(sagaRepositoryContext).ConfigureAwait(false);

            databaseContext.Commit();

            return(result);
        }
Ejemplo n.º 3
0
        public async Task SendQuery <T>(ConsumeContext <T> context, ISagaQuery <TSaga> query, IPipe <SagaRepositoryQueryContext <TSaga, T> > next)
            where T : class
        {
            using DapperDatabaseContext <TSaga> databaseContext = await CreateDatabaseContext(context.CancellationToken).ConfigureAwait(false);

            IEnumerable <TSaga> instances = await databaseContext.QueryAsync(query.FilterExpression, context.CancellationToken).ConfigureAwait(false);

            var repositoryContext = new DapperSagaRepositoryContext <TSaga, T>(databaseContext, context, _factory);

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

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

            databaseContext.Commit();
        }