Example #1
0
        public UnitOfWork(UnitOfWorkScopeType scopeType)
        {
            _preCommitActions = new List<Action>();

            switch (scopeType)
            {
                case UnitOfWorkScopeType.New:
                    _transactionScope = new TransactionScope(TransactionScopeOption.RequiresNew);
                    _unitOfWorkScope = new UnitOfWorkScope(scopeType);
                    break;
                default:
                    _transactionScope = new TransactionScope(TransactionScopeOption.RequiresNew);
                    _unitOfWorkScope = UnitOfWorkManager.Instance.CurrentUnitOfWorkScope ?? new UnitOfWorkScope(scopeType);
                    break;
            }
            _unitOfWorkScope.Units.Add(this);
        }
Example #2
0
        public UnitOfWork(UnitOfWorkScopeType scopeType)
        {
            _preCommitActions = new List <Action>();

            switch (scopeType)
            {
            case UnitOfWorkScopeType.New:
                _transactionScope = new TransactionScope(TransactionScopeOption.RequiresNew);
                _unitOfWorkScope  = new UnitOfWorkScope(scopeType);
                break;

            default:
                _transactionScope = new TransactionScope(TransactionScopeOption.RequiresNew);
                _unitOfWorkScope  = UnitOfWorkManager.Instance.CurrentUnitOfWorkScope ?? new UnitOfWorkScope(scopeType);
                break;
            }
            _unitOfWorkScope.Units.Add(this);
        }
Example #3
0
        internal UnitOfWorkScope(UnitOfWorkScopeType scopeType)
        {
            _scopeType = scopeType;
            _units = new List<UnitOfWork>();
            _postCommitActions = new List<Action>();
            _postRollbackActions = new List<Action>();

            var repositoryHelper = IoC.Resolve<IDataRepositoryManager>();
            switch (scopeType)
            {
                case UnitOfWorkScopeType.New:
                    _repository = repositoryHelper.GetNewRepository();
                    break;
                default:
                    _repository = repositoryHelper.GetCurrentRepository();
                    break;
            }
            _repository.Transaction.Initialize();
            _transactionId = Transaction.Current.TransactionInformation.LocalIdentifier;
            UnitOfWorkManager.Instance.AddUnitOfWorkScope(_transactionId, this);
        }
Example #4
0
        internal UnitOfWorkScope(UnitOfWorkScopeType scopeType)
        {
            _scopeType           = scopeType;
            _units               = new List <UnitOfWork>();
            _postCommitActions   = new List <Action>();
            _postRollbackActions = new List <Action>();

            var repositoryHelper = IoC.Resolve <IDataRepositoryManager>();

            switch (scopeType)
            {
            case UnitOfWorkScopeType.New:
                _repository = repositoryHelper.GetNewRepository();
                break;

            default:
                _repository = repositoryHelper.GetCurrentRepository();
                break;
            }
            _repository.Transaction.Initialize();
            _transactionId = Transaction.Current.TransactionInformation.LocalIdentifier;
            UnitOfWorkManager.Instance.AddUnitOfWorkScope(_transactionId, this);
        }