Beispiel #1
0
        public override void Close()
        {
            InnerConnection.CloseConnection(this, ConnectionFactory);

            OdbcConnectionHandle connectionHandle = _connectionHandle;

            if (null != connectionHandle)
            {
                _connectionHandle = null;

                // If there is a pending transaction, automatically rollback.
                WeakReference weak = _weakTransaction;
                if (null != weak)
                {
                    _weakTransaction = null;
                    IDisposable transaction = weak.Target as OdbcTransaction;
                    if ((null != transaction) && weak.IsAlive)
                    {
                        transaction.Dispose();
                    }
                    // else transaction will be rolled back when handle is disposed
                }
                connectionHandle.Dispose();
            }
        }
Beispiel #2
0
        public override void Close()
        {
            this.InnerConnection.CloseConnection(this, this.ConnectionFactory);
            OdbcConnectionHandle handle = this._connectionHandle;

            if (handle != null)
            {
                this._connectionHandle = null;
                WeakReference weakTransaction = this.weakTransaction;
                if (weakTransaction != null)
                {
                    this.weakTransaction = null;
                    IDisposable target = weakTransaction.Target as OdbcTransaction;
                    if ((target != null) && weakTransaction.IsAlive)
                    {
                        target.Dispose();
                    }
                }
                handle.Dispose();
            }
        }