/// <summary> /// Create a new unit of work scope. /// </summary> public UnitOfWorkScope(bool isTransactional) { //There is already a uow, do nothing if (Current != null) { return; } //this scope started the uow _isStartedByThisScope = true; _unitOfWorkWrapper = IocHelper.ResolveAsDisposable<IUnitOfWork>(); Current = _unitOfWorkWrapper.Object; try { Current.Initialize(isTransactional); Current.Begin(); } catch { Current = null; _unitOfWorkWrapper.Dispose(); throw; } }
/// <summary> /// Create a new unit of work scope. /// </summary> public UnitOfWorkScope(bool isTransactional) { //There is already a uow, do nothing if (Current != null) { return; } //this scope started the uow _isStartedByThisScope = true; _unitOfWorkWrapper = IocManager.Instance.ResolveAsDisposable <IUnitOfWork>(); Current = _unitOfWorkWrapper.Object; try { Current.Initialize(isTransactional); Current.Begin(); } catch { Current = null; _unitOfWorkWrapper.Dispose(); throw; } }
public void Dispose() { if (!_isCommited) { try { _unitOfWorkWrapper.Object.Rollback(); } catch { } } CurrentUow = null; _unitOfWorkWrapper.Dispose(); }
public void Dispose() { if (!_isStartedByThisScope) { //if this scope did not started the uow, do nothing return; } if (!_isCommited) { try { Current.Cancel(); } catch { } //Hide errors } Current = null; _unitOfWorkWrapper.Dispose(); }