Beispiel #1
0
        public override async Task Invoke(AspectContext context, AspectDelegate next)
        {
            var dbContext = context.ServiceProvider.GetService(DbType) as IDbContext;

            if (dbContext == null)
            {
                throw new ArgumentNullException("DbType is null");
            }

            IUnitOfWork unitOfWork = new UnitOfWorkService(dbContext);

            await unitOfWork.CreateTransactionAsync(
                async (tran, cancel) =>
            {
                await next(context);
            },
                async (tran, error, cancel) =>
            {
                await Task.CompletedTask;

                throw error;
            },
                CancellationToken.None);
        }