コード例 #1
0
        /// <summary>
        /// Instantiate an opened connection enlisted to the Transaction
        /// if promotable is false, the Transaction wraps a local 
        /// transaction inside and can never be promoted
        /// </summary>
        /// <param name="dbResourceAllocator"></param>
        /// <param name="transaction"></param>
        /// <param name="wantPromotable"></param>
        internal SharedConnectionInfo(
            DbResourceAllocator dbResourceAllocator,
            Transaction transaction,
            bool wantPromotable,
            ManualResetEvent handle)
        {
            Debug.Assert((transaction != null), "Null Transaction!");

            if (null == handle)
                throw new ArgumentNullException("handle");

            this.handle = handle;

            if (wantPromotable)
            {
                // Enlist a newly opened connection to this regular Transaction
                this.connection = dbResourceAllocator.OpenNewConnection();
                this.connection.EnlistTransaction(transaction);
            }
            else
            {
                // Make this transaction no longer promotable by attaching our 
                // IPromotableSinglePhaseNotification implementation (LocalTranscaction)
                // and track the DbConnection and DbTransaction associated with the LocalTranscaction
                LocalTransaction localTransaction = new LocalTransaction(dbResourceAllocator, handle);
                transaction.EnlistPromotableSinglePhase(localTransaction);
                this.connection = localTransaction.Connection;
                this.localTransaction = localTransaction.Transaction;
            }
        }
コード例 #2
0
        /// <summary>
        /// Instantiate an opened connection enlisted to the Transaction
        /// if promotable is false, the Transaction wraps a local
        /// transaction inside and can never be promoted
        /// </summary>
        /// <param name="dbResourceAllocator"></param>
        /// <param name="transaction"></param>
        /// <param name="wantPromotable"></param>
        internal SharedConnectionInfo(
            DbResourceAllocator dbResourceAllocator,
            Transaction transaction,
            bool wantPromotable,
            ManualResetEvent handle)
        {
            Debug.Assert((transaction != null), "Null Transaction!");

            if (null == handle)
            {
                throw new ArgumentNullException("handle");
            }

            this.handle = handle;

            if (wantPromotable)
            {
                // Enlist a newly opened connection to this regular Transaction
                this.connection = dbResourceAllocator.OpenNewConnection();
                this.connection.EnlistTransaction(transaction);
            }
            else
            {
                // Make this transaction no longer promotable by attaching our
                // IPromotableSinglePhaseNotification implementation (LocalTranscaction)
                // and track the DbConnection and DbTransaction associated with the LocalTranscaction
                LocalTransaction localTransaction = new LocalTransaction(dbResourceAllocator, handle);
                transaction.EnlistPromotableSinglePhase(localTransaction);
                this.connection       = localTransaction.Connection;
                this.localTransaction = localTransaction.Transaction;
            }
        }
コード例 #3
0
 internal SharedConnectionInfo(DbResourceAllocator dbResourceAllocator, Transaction transaction, bool wantPromotable, ManualResetEvent handle)
 {
     if (handle == null)
     {
         throw new ArgumentNullException("handle");
     }
     this.handle = handle;
     if (wantPromotable)
     {
         this.connection = dbResourceAllocator.OpenNewConnection();
         this.connection.EnlistTransaction(transaction);
     }
     else
     {
         LocalTransaction promotableSinglePhaseNotification = new LocalTransaction(dbResourceAllocator, handle);
         transaction.EnlistPromotableSinglePhase(promotableSinglePhaseNotification);
         this.connection       = promotableSinglePhaseNotification.Connection;
         this.localTransaction = promotableSinglePhaseNotification.Transaction;
     }
 }
 internal SharedConnectionInfo(DbResourceAllocator dbResourceAllocator, Transaction transaction, bool wantPromotable, ManualResetEvent handle)
 {
     if (handle == null)
     {
         throw new ArgumentNullException("handle");
     }
     this.handle = handle;
     if (wantPromotable)
     {
         this.connection = dbResourceAllocator.OpenNewConnection();
         this.connection.EnlistTransaction(transaction);
     }
     else
     {
         LocalTransaction promotableSinglePhaseNotification = new LocalTransaction(dbResourceAllocator, handle);
         transaction.EnlistPromotableSinglePhase(promotableSinglePhaseNotification);
         this.connection = promotableSinglePhaseNotification.Connection;
         this.localTransaction = promotableSinglePhaseNotification.Transaction;
     }
 }