#region Apache Notice /***************************************************************************** * $Header: $ * $Revision: $ * $Date: $ * * iBATIS.NET Data Mapper * Copyright (C) 2004 - Gilles Bayon * * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ********************************************************************************/ #endregion #region Imports using System; using System.Data; using IBatisNet.Common; using IBatisNet.DataAccess; using IBatisNet.DataAccess.Exceptions; using IBatisNet.DataAccess.Interfaces; using IBatisNet.DataMapper; #endregion namespace IBatisNet.DataAccess.DaoSessionHandlers { /// /// An SqlMappper implementation of the DataAccess Session. /// public class SqlMapDaoSession : DaoSession { #region Fields private SqlMapper _sqlMap = null; #endregion #region Properties /// /// /// public SqlMapper SqlMap { get { return _sqlMap; } } /// /// /// public override DataSource DataSource { get { return _sqlMap.LocalSession.DataSource; } } /// /// /// public override IDbConnection Connection { get { return _sqlMap.LocalSession.Connection; } } /// /// /// public override IDbTransaction Transaction { get { return _sqlMap.LocalSession.Transaction; } } #endregion #region Constructor (s) / Destructor /// /// /// /// /// public SqlMapDaoSession(DaoManager daoManager, SqlMapper sqlMap):base(daoManager) { _sqlMap = sqlMap; } #endregion #region Methods /// /// Complete (commit) a transaction /// /// /// Use in 'using' syntax. /// public override void Complete() { _sqlMap.LocalSession.Complete(); } /// /// Opens a database connection. /// public override void OpenConnection() { _sqlMap.OpenConnection(); } /// /// Open a connection, on the specified connection string. /// /// The connection string public override void OpenConnection(string connectionString) { _sqlMap.OpenConnection(connectionString); } /// /// Closes the connection /// public override void CloseConnection() { _sqlMap.CloseConnection(); } /// /// Begins a transaction. /// public override void BeginTransaction() { _sqlMap.BeginTransaction(); } /// /// Open a connection and begin a transaction on the specified connection string. /// /// The connection string public override void BeginTransaction(string connectionString) { _sqlMap.BeginTransaction( connectionString ); } /// /// Begins a database transaction /// /// Open a connection. public override void BeginTransaction(bool openConnection) { _sqlMap.BeginTransaction(openConnection); } /// /// Begins a transaction at the data source with the specified IsolationLevel value. /// /// The transaction isolation level for this connection. public override void BeginTransaction(IsolationLevel isolationLevel) { _sqlMap.BeginTransaction (isolationLevel); } /// /// Open a connection and begin a transaction on the specified connection string. /// /// The connection string /// The transaction isolation level for this connection. public override void BeginTransaction(string connectionString, IsolationLevel isolationLevel) { _sqlMap.BeginTransaction ( connectionString, isolationLevel ); } /// /// Begins a transaction on the current connection /// with the specified IsolationLevel value. /// /// The transaction isolation level for this connection. /// Open a connection. public override void BeginTransaction(bool openConnection, IsolationLevel isolationLevel) { _sqlMap.BeginTransaction(openConnection, isolationLevel); } /// /// Begins a transaction on the current connection /// with the specified IsolationLevel value. /// /// The transaction isolation level for this connection. /// The connection string /// Open a connection. public override void BeginTransaction(string connectionString, bool openConnection, IsolationLevel isolationLevel) { _sqlMap.BeginTransaction( connectionString, openConnection, isolationLevel ); } /// /// Commits the database transaction. /// /// /// Will close the connection. /// public override void CommitTransaction() { _sqlMap.CommitTransaction(); } /// /// Commits the database transaction. /// /// Close the connection public override void CommitTransaction(bool closeConnection) { _sqlMap.CommitTransaction(closeConnection); } /// /// Rolls back a transaction from a pending state. /// /// /// Will close the connection. /// public override void RollBackTransaction() { _sqlMap.RollBackTransaction(); } /// /// Rolls back a transaction from a pending state. /// /// Close the connection public override void RollBackTransaction(bool closeConnection) { _sqlMap.RollBackTransaction(closeConnection); } /// /// /// /// /// public override IDbCommand CreateCommand(CommandType commandType) { return _sqlMap.LocalSession.CreateCommand(commandType); } /// /// /// /// public override IDataParameter CreateDataParameter() { return _sqlMap.LocalSession.CreateDataParameter(); } /// /// /// /// public override IDbDataAdapter CreateDataAdapter() { return _sqlMap.LocalSession.CreateDataAdapter(); } /// /// /// /// /// public override IDbDataAdapter CreateDataAdapter(IDbCommand command) { return _sqlMap.LocalSession.CreateDataAdapter(command); } #endregion #region IDisposable Members /// /// Releasing, or resetting resources. /// public override void Dispose() { _sqlMap.LocalSession.Dispose(); daoManager.Dispose(); } #endregion } }