Пример #1
0
        /// <summary>
        /// Builds the command to be executed
        /// </summary>
        /// <returns>Prepared IDbCommand</returns>
        protected virtual IDbCommand PrepareCommand()
        {
            IDbCommand command = this.Connection.CreateCommand();

            command.CommandType = this.CommandType;
            command.CommandText = this.CommandText;
            //join transaction if present:
            if (TransactionBase <TConnection> .InTransactionScope(this))
            {
                command.Transaction = TransactionBase <TConnection> .Current;
            }
            this.SetCommandTimeout(command);
            return(command);
        }
Пример #2
0
 /// <summary>
 /// Cleans up database resources
 /// </summary>
 /// <param name="disposing">Whether disposing</param>
 protected virtual void Dispose(bool disposing)
 {
     if (disposing && this._connection != null)
     {
         //check if this connection is part of a transaction:
         if (TransactionBase <TConnection> .InTransactionScope(this))
         {
             //if so, do nothing - the connection will be closed when the
             //transaction is disposed
         }
         else
         {
             //otherwise, this is a solo connection, so dispose it:
             if (this._connection.State == ConnectionState.Open)
             {
                 this._connection.Close();
             }
             this._connection.Dispose();
             this._connection = null;
         }
     }
 }