示例#1
0
 internal DataAccessTransaction(DataAccessIsolationLevel isolationLevel, DataAccessScope scope, TimeSpan timeout)
 {
     this.timeout           = timeout;
     this.scope             = scope;
     this.IsolationLevel    = isolationLevel;
     this.SystemTransaction = Transaction.Current;
 }
        public static IsolationLevel ConvertIsolationLevel(DataAccessIsolationLevel isolationLevel)
        {
            switch (isolationLevel)
            {
            case DataAccessIsolationLevel.ReadUncommitted:
                return(IsolationLevel.ReadUncommitted);

            case DataAccessIsolationLevel.Serializable:
                return(IsolationLevel.Serializable);

            case DataAccessIsolationLevel.ReadCommitted:
                return(IsolationLevel.ReadCommitted);

            case DataAccessIsolationLevel.Chaos:
                return(IsolationLevel.Chaos);

            case DataAccessIsolationLevel.RepeatableRead:
                return(IsolationLevel.RepeatableRead);

            case DataAccessIsolationLevel.Snapshot:
                return(IsolationLevel.Snapshot);

            default:
                return(IsolationLevel.Unspecified);
            }
        }
示例#3
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;
            }
        }
示例#4
0
        internal DataAccessTransaction(DataAccessIsolationLevel isolationLevel, TimeSpan timeout)
        {
            this.timeout           = timeout;
            this.IsolationLevel    = isolationLevel;
            this.SystemTransaction = Transaction.Current;

            if (this.SystemTransaction != null)
            {
                this.previousTransaction = Current;

                this.SystemTransaction.TransactionCompleted += (sender, eventArgs) =>
                {
                    this.systemTransactionCompleted = true;
                    this.systemTransactionStatus    = eventArgs.Transaction.TransactionInformation.Status;

                    this.Dispose();
                };
            }
        }
		public static IsolationLevel ConvertIsolationLevel(DataAccessIsolationLevel isolationLevel)
		{
			switch (isolationLevel)
			{
			case DataAccessIsolationLevel.ReadUncommitted:
				return IsolationLevel.ReadUncommitted;
			case DataAccessIsolationLevel.Serializable:
				return IsolationLevel.Serializable;
			case DataAccessIsolationLevel.ReadCommitted:
				return IsolationLevel.ReadCommitted;
			case DataAccessIsolationLevel.Chaos:
				return IsolationLevel.Chaos;
			case DataAccessIsolationLevel.RepeatableRead:
				return IsolationLevel.RepeatableRead;
			case DataAccessIsolationLevel.Snapshot:
				return IsolationLevel.Snapshot;
			default:
				return IsolationLevel.Unspecified;
			}
		}
        internal DataAccessTransaction(DataAccessIsolationLevel isolationLevel, TimeSpan timeout)
        {
            this.timeout           = timeout;
            this.IsolationLevel    = isolationLevel;
            this.SystemTransaction = Transaction.Current;

            if (this.SystemTransaction != null)
            {
                this.previousTransaction = Current;

                this.SystemTransaction.TransactionCompleted += (sender, eventArgs) =>
                {
                    this.systemTransactionCompleted = true;
                    this.systemTransactionStatus    = eventArgs.Transaction.TransactionInformation.Status;

                    Dispose();
                };
            }

            this.DataAccessTransactionId = this.SystemTransaction?.TransactionInformation.LocalIdentifier ??
                                           Guid.NewGuid().ToString("N");
        }
示例#7
0
 internal DataAccessTransaction(DataAccessIsolationLevel isolationLevel)
     : this(isolationLevel, TimeSpan.Zero)
 {
 }
示例#8
0
 public DataAccessScope(DataAccessIsolationLevel isolationLevel, TimeSpan timeout)
     : this(isolationLevel, DataAccessScopeOptions.Required, timeout)
 {
 }
示例#9
0
 public DataAccessScope(DataAccessIsolationLevel isolationLevel)
     : this(isolationLevel, TimeSpan.Zero)
 {
 }
示例#10
0
		public DataAccessScope(DataAccessIsolationLevel isolationLevel, TimeSpan timeout)
			: this(isolationLevel, DataAccessScopeOptions.Required, timeout)
		{
		}
示例#11
0
		public DataAccessScope(DataAccessIsolationLevel isolationLevel)
			: this(isolationLevel, TimeSpan.Zero)
		{
		}
示例#12
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;
			}
		}
示例#13
0
 internal DataAccessTransaction(DataAccessIsolationLevel isolationLevel)
 {
     this.IsolationLevel    = isolationLevel;
     this.SystemTransaction = Transaction.Current;
 }