public override async Task InterceptAsync(IAbpMethodInvocation invocation) { if (!UnitOfWorkHelper.IsUnitOfWorkMethod(invocation.Method, out var unitOfWorkAttribute)) { await invocation.ProceedAsync(); return; } var options = CreateOptions(invocation, unitOfWorkAttribute); //Trying to begin a reserved UOW by AbpUnitOfWorkMiddleware if (_unitOfWorkManager.TryBeginReserved(UnitOfWork.UnitOfWorkReservationName, options)) { await invocation.ProceedAsync(); return; } using (var uow = _unitOfWorkManager.Begin(options)) { await invocation.ProceedAsync(); await uow.CompleteAsync(); } }
public override async Task InterceptAsync(IAbpMethodInvocation invocation) { if (!UnitOfWorkHelper.IsUnitOfWorkMethod(invocation.Method, out var unitOfWorkAttribute)) { await invocation.ProceedAsync(); return; } using (var scope = _serviceScopeFactory.CreateScope()) { var options = CreateOptions(scope.ServiceProvider, invocation, unitOfWorkAttribute); var unitOfWorkManager = scope.ServiceProvider.GetRequiredService <IUnitOfWorkManager>(); //Trying to begin a reserved UOW by AbpUnitOfWorkMiddleware if (unitOfWorkManager.TryBeginReserved(UnitOfWork.UnitOfWorkReservationName, options)) { await invocation.ProceedAsync(); return; } using (var uow = unitOfWorkManager.Begin(options)) { await invocation.ProceedAsync(); await uow.CompleteAsync(); } } }
public override void Intercept(IAbpMethodInvocation invocation) { if (!UnitOfWorkHelper.IsUnitOfWorkMethod(invocation.Method, out var unitOfWorkAttribute)) { invocation.Proceed(); return; } using (var uow = _unitOfWorkManager.Begin(CreateOptions(invocation, unitOfWorkAttribute))) { invocation.Proceed(); uow.Complete(); } }
public override async Task InterceptAsync(IAbpMethodInvocation invocation) { if (!UnitOfWorkHelper.IsUnitOfWorkMethod(invocation.Method, out var unitOfWorkAttribute)) { await invocation.ProceedAsync(); return; } using (var uow = _unitOfWorkManager.Begin(CreateOptions(invocation, unitOfWorkAttribute))) { await invocation.ProceedAsync(); await uow.CompleteAsync(); } }