Exemplo n.º 1
0
        public DataAccessScope(DataAccessIsolationLevel isolationLevel, DataAccessScopeOptions options, TimeSpan timeout)
        {
            this.IsolationLevel = isolationLevel;
            var currentTransaction = DataAccessTransaction.Current;

            this.options = options;

            switch (options)
            {
            case DataAccessScopeOptions.Required:
                if (currentTransaction == null)
                {
                    this.isRoot      = true;
                    this.transaction = new DataAccessTransaction(isolationLevel, timeout);
                    DataAccessTransaction.Current = this.transaction;
                }
                else
                {
                    this.transaction      = currentTransaction;
                    this.outerTransaction = currentTransaction;
                }
                break;

            case DataAccessScopeOptions.RequiresNew:
                this.isRoot           = true;
                this.outerTransaction = currentTransaction;
                if (Transaction.Current != null)
                {
                    this.nativeScope = new TransactionScope(TransactionScopeOption.RequiresNew);
                }
                this.transaction = new DataAccessTransaction(isolationLevel, timeout);
                DataAccessTransaction.Current = this.transaction;
                break;

            case DataAccessScopeOptions.Suppress:
                if (Transaction.Current != null)
                {
                    this.nativeScope = new TransactionScope(TransactionScopeOption.Suppress);
                }
                if (currentTransaction != null)
                {
                    this.outerTransaction         = currentTransaction;
                    DataAccessTransaction.Current = null;
                }
                break;
            }
        }
Exemplo n.º 2
0
 public DataAccessScope(DataAccessScopeOptions options)
     : this(DataAccessIsolationLevel.Unspecified, options, TimeSpan.Zero)
 {
 }
Exemplo n.º 3
0
		public DataAccessScope(DataAccessScopeOptions options)
			: this(DataAccessIsolationLevel.Unspecified, options, TimeSpan.Zero)
		{
		}
Exemplo n.º 4
0
		public DataAccessScope(DataAccessIsolationLevel isolationLevel, DataAccessScopeOptions options, TimeSpan timeout)
		{
			this.IsolationLevel = isolationLevel;
			var currentTransaction = DataAccessTransaction.Current;

			this.options = options;

			switch (options)
			{
			case DataAccessScopeOptions.Required:
				if (currentTransaction == null)
				{
					this.isRoot = true;
					this.transaction = new DataAccessTransaction(isolationLevel, timeout);
					DataAccessTransaction.Current = this.transaction;
				}
				else
				{
					this.transaction = currentTransaction;
					this.outerTransaction = currentTransaction;
				}
				break;
			case DataAccessScopeOptions.RequiresNew:
				this.isRoot = true;
				this.outerTransaction = currentTransaction;
				if (Transaction.Current != null)
				{
					this.nativeScope = new TransactionScope(TransactionScopeOption.RequiresNew);
				}
				this.transaction = new DataAccessTransaction(isolationLevel, timeout);
				DataAccessTransaction.Current = this.transaction;
				break;
			case DataAccessScopeOptions.Suppress:
				if (Transaction.Current != null)
				{
					this.nativeScope = new TransactionScope(TransactionScopeOption.Suppress);
				}
				if (currentTransaction != null)
				{
					this.outerTransaction = currentTransaction;
					DataAccessTransaction.Current = null;
				}
				break;
			}
		}