示例#1
0
        protected Session(string connectionString, IsolationLevel isoLevel)
        {
            //New session
            this.SessionID = Guid.NewGuid();

            //Create new connection unique to this session
            this._Connection = Connection.GetConnection(this.SessionID.ToString(), connectionString, true);
            this._Transaction = new Transaction(this._Connection, this.SessionID, isoLevel);

            //Add it to the session manager
            Session._manager.Add(this);
        }
示例#2
0
        protected Session(Session parent, IsolationLevel isoLevel)
        {
            //Nested Session
            this.SessionID = Guid.NewGuid();

            //Create savepoint transaction
            this._Connection = parent._Connection;
            this._Transaction = new Transaction(parent.Connection, this.SessionID, isoLevel);

            //Set parent/child stuff
            this.Parent = parent;
            this.Parent.Children.Add(this);
        }
示例#3
0
        /// <summary>
        /// On end of session, we need to commit or rollback the nested transaction
        /// </summary>
        public void Dispose()
        {
            //The transaction MUST be disposed FIRST to remove themselves from the connection
            this.Transaction.Dispose();
            this._Transaction = null;

            //Only root sessions should dispose of the connection
            if (this.Parent == null)
            {
                this.Connection.Dispose();
                Session._manager.Remove();
                this._Connection = null;
            }
        }
示例#4
0
 /// <summary>
 /// Called by the Transaction class when the transaction has ended
 /// </summary>
 internal void TransactionEnded()
 {
     this._ActiveTransaction = null;
 }