#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.Data;
using IBatisNet.Common;
using IBatisNet.DataMapper;
#endregion
namespace IBatisNet.DataAccess.DaoSessionHandlers
{
///
/// An SqlMappper implementation of the DataAccess Session.
///
public class SqlMapDaoSession : DaoSession
{
#region Fields
private ISqlMapper _sqlMap = null;
#endregion
#region Properties
///
/// Gets the SQL map.
///
/// The SQL map.
public ISqlMapper SqlMap
{
get { return _sqlMap; }
}
///
/// The data source use by the session.
///
///
public override IDataSource DataSource
{
get { return _sqlMap.LocalSession.DataSource; }
}
///
/// The Connection use by the session.
///
///
public override IDbConnection Connection
{
get { return _sqlMap.LocalSession.Connection; }
}
///
/// The Transaction use by the session.
///
///
public override IDbTransaction Transaction
{
get { return _sqlMap.LocalSession.Transaction; }
}
///
/// Indicates if a transaction is open on
/// the session.
///
///
public override bool IsTransactionStart
{
get { return _sqlMap.LocalSession.IsTransactionStart; }
}
#endregion
#region Constructor (s) / Destructor
///
///
///
///
///
public SqlMapDaoSession(DaoManager daoManager, ISqlMapper 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 IDbDataParameter 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
}
}