349 lines
14 KiB
C#
349 lines
14 KiB
C#
|
using System;
|
||
|
using System.Data;
|
||
|
using Ease.Core.DataAccess.SQL;
|
||
|
//using Ease.Core.DataAccess.Odbc;
|
||
|
//using Ease.Core.DataAccess.OleDb;
|
||
|
using Ease.Core.DataAccess.Oracle;
|
||
|
|
||
|
namespace Ease.Core.DataAccess
|
||
|
{
|
||
|
#region DataAccess: Transaction Helper Factory
|
||
|
|
||
|
public abstract class TransactionFactory
|
||
|
{
|
||
|
#region Default Helper
|
||
|
|
||
|
private static TransactionFactory _default;
|
||
|
|
||
|
public static TransactionFactory Default
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
if (_default == null)
|
||
|
{
|
||
|
#region Default TransactionHelper
|
||
|
|
||
|
switch (ConnectionFactory.Provider)
|
||
|
{
|
||
|
case Provider.Sql:
|
||
|
_default = new SqlHelper();
|
||
|
break;
|
||
|
case Provider.Oracle:
|
||
|
//_default = new OracleHelper();
|
||
|
break;
|
||
|
|
||
|
case Provider.OleDb:
|
||
|
//_default = new OleDbHelper();
|
||
|
break;
|
||
|
|
||
|
case Provider.Odbc:
|
||
|
//_default = new OdbcHelper();
|
||
|
break;
|
||
|
|
||
|
default:
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
}
|
||
|
|
||
|
return _default;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region Context Helper
|
||
|
|
||
|
public static TransactionFactory ContextTransactionHelper(ConnectionContext context)
|
||
|
{
|
||
|
TransactionFactory ctxFactory;
|
||
|
|
||
|
switch (ConnectionFactory.Provider)
|
||
|
{
|
||
|
//case Provider.Oracle:
|
||
|
// ctxFactory = new OracleHelper();
|
||
|
// break;
|
||
|
|
||
|
//case Provider.OleDb:
|
||
|
// ctxFactory = new OleDbHelper();
|
||
|
// break;
|
||
|
|
||
|
//case Provider.Odbc:
|
||
|
// ctxFactory = new OdbcHelper();
|
||
|
// break;
|
||
|
|
||
|
default:
|
||
|
ctxFactory = new SqlHelper();
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
return ctxFactory;
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region Execute NonQuery
|
||
|
|
||
|
public abstract int ExecuteNonQuery(int commandTimeout, string connectionString, CommandType commandType,
|
||
|
string commandText);
|
||
|
|
||
|
public abstract int ExecuteNonQuery(int commandTimeout, string connectionString, CommandType commandType,
|
||
|
string commandText, params IDataParameter[] commandParameters);
|
||
|
|
||
|
public abstract int ExecuteNonQuery(int commandTimeout, string connectionString, string spName,
|
||
|
params object[] parameterValues);
|
||
|
|
||
|
public abstract int ExecuteNonQuery(int commandTimeout, IDbConnection connection, CommandType commandType,
|
||
|
string commandText);
|
||
|
|
||
|
public abstract int ExecuteNonQuery(int commandTimeout, IDbConnection connection, CommandType commandType,
|
||
|
string commandText, params IDataParameter[] commandParameters);
|
||
|
|
||
|
public abstract int ExecuteNonQuery(int commandTimeout, IDbConnection connection, string spName,
|
||
|
params object[] parameterValues);
|
||
|
|
||
|
public abstract int ExecuteNonQuery(int commandTimeout, IDbTransaction transaction, CommandType commandType,
|
||
|
string commandText);
|
||
|
|
||
|
public abstract int ExecuteNonQuery(int commandTimeout, IDbTransaction transaction, CommandType commandType,
|
||
|
string commandText, params IDataParameter[] commandParameters);
|
||
|
|
||
|
public abstract int ExecuteNonQuery(int commandTimeout, IDbTransaction transaction, string spName,
|
||
|
params object[] parameterValues);
|
||
|
|
||
|
#endregion ExecuteNonQuery
|
||
|
|
||
|
#region Execute DataTable
|
||
|
|
||
|
public abstract DataTable ExecuteDataTable(int commandTimeout, string connectionString, CommandType commandType,
|
||
|
string commandText);
|
||
|
|
||
|
public abstract DataTable ExecuteDataTable(int commandTimeout, string connectionString, CommandType commandType,
|
||
|
string commandText, params IDataParameter[] commandParameters);
|
||
|
|
||
|
public abstract DataTable ExecuteDataTable(int commandTimeout, string connectionString, string spName,
|
||
|
params object[] parameterValues);
|
||
|
|
||
|
public abstract DataTable ExecuteDataTable(int commandTimeout, IDbConnection connection,
|
||
|
CommandType commandType, string commandText);
|
||
|
|
||
|
public abstract DataTable ExecuteDataTable(int commandTimeout, IDbConnection connection,
|
||
|
CommandType commandType, string commandText, params IDataParameter[] commandParameters);
|
||
|
|
||
|
public abstract DataTable ExecuteDataTable(int commandTimeout, IDbConnection connection, string spName,
|
||
|
params object[] parameterValues);
|
||
|
|
||
|
public abstract DataTable ExecuteDataTable(int commandTimeout, IDbTransaction transaction,
|
||
|
CommandType commandType, string commandText);
|
||
|
|
||
|
public abstract DataTable ExecuteDataTable(int commandTimeout, IDbTransaction transaction,
|
||
|
CommandType commandType, string commandText, params IDataParameter[] commandParameters);
|
||
|
|
||
|
public abstract DataTable ExecuteDataTable(int commandTimeout, IDbTransaction transaction, string spName,
|
||
|
params object[] parameterValues);
|
||
|
|
||
|
#endregion ExecuteDataTable
|
||
|
|
||
|
#region Execute Dataset
|
||
|
|
||
|
public abstract DataSet ExecuteDataset(int commandTimeout, string connectionString, CommandType commandType,
|
||
|
string commandText);
|
||
|
|
||
|
public abstract DataSet ExecuteDataset(int commandTimeout, string connectionString, CommandType commandType,
|
||
|
string commandText, params IDataParameter[] commandParameters);
|
||
|
|
||
|
public abstract DataSet ExecuteDataset(int commandTimeout, string connectionString, string spName,
|
||
|
params object[] parameterValues);
|
||
|
|
||
|
public abstract DataSet ExecuteDataset(int commandTimeout, IDbConnection connection, CommandType commandType,
|
||
|
string commandText);
|
||
|
|
||
|
public abstract DataSet ExecuteDataset(int commandTimeout, IDbConnection connection, CommandType commandType,
|
||
|
string commandText, params IDataParameter[] commandParameters);
|
||
|
|
||
|
public abstract DataSet ExecuteDataset(int commandTimeout, IDbConnection connection, string spName,
|
||
|
params object[] parameterValues);
|
||
|
|
||
|
public abstract DataSet ExecuteDataset(int commandTimeout, IDbTransaction transaction, CommandType commandType,
|
||
|
string commandText);
|
||
|
|
||
|
public abstract DataSet ExecuteDataset(int commandTimeout, IDbTransaction transaction, CommandType commandType,
|
||
|
string commandText, params IDataParameter[] commandParameters);
|
||
|
|
||
|
public abstract DataSet ExecuteDataset(int commandTimeout, IDbTransaction transaction, string spName,
|
||
|
params object[] parameterValues);
|
||
|
|
||
|
#endregion ExecuteDataset
|
||
|
|
||
|
#region Execute Reader
|
||
|
|
||
|
private enum IDbConnectionOwnership
|
||
|
{
|
||
|
/// <summary>Connection is owned and managed by OleDbHelper</summary>
|
||
|
Internal,
|
||
|
|
||
|
/// <summary>Connection is owned and managed by the caller</summary>
|
||
|
External
|
||
|
}
|
||
|
|
||
|
public abstract IDataReader ExecuteReader(int commandTimeout, string connectionString, CommandType commandType,
|
||
|
string commandText);
|
||
|
|
||
|
public abstract IDataReader ExecuteReader(int commandTimeout, string connectionString, CommandType commandType,
|
||
|
string commandText, params IDataParameter[] commandParameters);
|
||
|
|
||
|
public abstract IDataReader ExecuteReader(int commandTimeout, string connectionString, string spName,
|
||
|
params object[] parameterValues);
|
||
|
|
||
|
public abstract IDataReader ExecuteReader(int commandTimeout, IDbConnection connection, CommandType commandType,
|
||
|
string commandText);
|
||
|
|
||
|
public abstract IDataReader ExecuteReader(int commandTimeout, IDbConnection connection, CommandType commandType,
|
||
|
string commandText, params IDataParameter[] commandParameters);
|
||
|
|
||
|
public abstract IDataReader ExecuteReader(int commandTimeout, IDbConnection connection, string spName,
|
||
|
params object[] parameterValues);
|
||
|
|
||
|
public abstract IDataReader ExecuteReader(int commandTimeout, IDbTransaction transaction,
|
||
|
CommandType commandType, string commandText);
|
||
|
|
||
|
public abstract IDataReader ExecuteReader(int commandTimeout, IDbTransaction transaction,
|
||
|
CommandType commandType, string commandText, params IDataParameter[] commandParameters);
|
||
|
|
||
|
public abstract IDataReader ExecuteReader(int commandTimeout, IDbTransaction transaction, string spName,
|
||
|
params object[] parameterValues);
|
||
|
|
||
|
#endregion ExecuteReader
|
||
|
|
||
|
#region Execute Scalar
|
||
|
|
||
|
public abstract object ExecuteScalar(int commandTimeout, string connectionString, CommandType commandType,
|
||
|
string commandText);
|
||
|
|
||
|
public abstract object ExecuteScalar(int commandTimeout, string connectionString, CommandType commandType,
|
||
|
string commandText, params IDataParameter[] commandParameters);
|
||
|
|
||
|
public abstract object ExecuteScalar(int commandTimeout, string connectionString, string spName,
|
||
|
params object[] parameterValues);
|
||
|
|
||
|
public abstract object ExecuteScalar(int commandTimeout, IDbConnection connection, CommandType commandType,
|
||
|
string commandText);
|
||
|
|
||
|
public abstract object ExecuteScalar(int commandTimeout, IDbConnection connection, CommandType commandType,
|
||
|
string commandText, params IDataParameter[] commandParameters);
|
||
|
|
||
|
public abstract object ExecuteScalar(int commandTimeout, IDbConnection connection, string spName,
|
||
|
params object[] parameterValues);
|
||
|
|
||
|
public abstract object ExecuteScalar(int commandTimeout, IDbTransaction transaction, CommandType commandType,
|
||
|
string commandText);
|
||
|
|
||
|
public abstract object ExecuteScalar(int commandTimeout, IDbTransaction transaction, CommandType commandType,
|
||
|
string commandText, params IDataParameter[] commandParameters);
|
||
|
|
||
|
public abstract object ExecuteScalar(int commandTimeout, IDbTransaction transaction, string spName,
|
||
|
params object[] parameterValues);
|
||
|
|
||
|
#endregion ExecuteScalar
|
||
|
|
||
|
#region FillDataset
|
||
|
|
||
|
public abstract void FillDataset(int commandTimeout, string connectionString, CommandType commandType,
|
||
|
string commandText, DataSet dataSet, string[] tableNames);
|
||
|
|
||
|
public abstract void FillDataset(int commandTimeout, string connectionString, CommandType commandType,
|
||
|
string commandText, DataSet dataSet, string[] tableNames, params IDataParameter[] commandParameters);
|
||
|
|
||
|
public abstract void FillDataset(int commandTimeout, string connectionString, string spName, DataSet dataSet,
|
||
|
string[] tableNames, params object[] parameterValues);
|
||
|
|
||
|
public abstract void FillDataset(int commandTimeout, IDbConnection connection, CommandType commandType,
|
||
|
string commandText, DataSet dataSet, string[] tableNames);
|
||
|
|
||
|
public abstract void FillDataset(int commandTimeout, IDbConnection connection, CommandType commandType,
|
||
|
string commandText, DataSet dataSet, string[] tableNames, params IDataParameter[] commandParameters);
|
||
|
|
||
|
public abstract void FillDataset(int commandTimeout, IDbConnection connection, string spName, DataSet dataSet,
|
||
|
string[] tableNames, params object[] parameterValues);
|
||
|
|
||
|
public abstract void FillDataset(int commandTimeout, IDbTransaction transaction, CommandType commandType,
|
||
|
string commandText, DataSet dataSet, string[] tableNames);
|
||
|
|
||
|
public abstract void FillDataset(int commandTimeout, IDbTransaction transaction, CommandType commandType,
|
||
|
string commandText, DataSet dataSet, string[] tableNames, params IDataParameter[] commandParameters);
|
||
|
|
||
|
public abstract void FillDataset(int commandTimeout, IDbTransaction transaction, string spName, DataSet dataSet,
|
||
|
string[] tableNames, params object[] parameterValues);
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region Update Dataset
|
||
|
|
||
|
public abstract void UpdateDataset(IDbCommand insertCommand, IDbCommand deleteCommand, IDbCommand updateCommand,
|
||
|
DataSet dataSet, string tableName);
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region Create Command
|
||
|
|
||
|
public abstract IDbCommand CreateCommand(IDbConnection connection, string spName,
|
||
|
params string[] sourceColumns);
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region Execute NonQuery TypedParams
|
||
|
|
||
|
public abstract int ExecuteNonQueryTypedParams(int commandTimeout, string connectionString, string spName,
|
||
|
DataRow dataRow);
|
||
|
|
||
|
public abstract int ExecuteNonQueryTypedParams(int commandTimeout, IDbConnection connection, string spName,
|
||
|
DataRow dataRow);
|
||
|
|
||
|
public abstract int ExecuteNonQueryTypedParams(int commandTimeout, IDbTransaction transaction, string spName,
|
||
|
DataRow dataRow);
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region Execute Dataset TypedParams
|
||
|
|
||
|
public abstract DataSet ExecuteDatasetTypedParams(int commandTimeout, string connectionString, string spName,
|
||
|
DataRow dataRow);
|
||
|
|
||
|
public abstract DataSet ExecuteDatasetTypedParams(int commandTimeout, IDbConnection connection, string spName,
|
||
|
DataRow dataRow);
|
||
|
|
||
|
public abstract DataSet ExecuteDatasetTypedParams(int commandTimeout, IDbTransaction transaction, string spName,
|
||
|
DataRow dataRow);
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region Execute Reader TypedParams
|
||
|
|
||
|
public abstract IDataReader ExecuteReaderTypedParams(int commandTimeout, string connectionString, string spName,
|
||
|
DataRow dataRow);
|
||
|
|
||
|
public abstract IDataReader ExecuteReaderTypedParams(int commandTimeout, IDbConnection connection,
|
||
|
string spName, DataRow dataRow);
|
||
|
|
||
|
public abstract IDataReader ExecuteReaderTypedParams(int commandTimeout, IDbTransaction transaction,
|
||
|
string spName, DataRow dataRow);
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region Execute Scalar TypedParams
|
||
|
|
||
|
public abstract object ExecuteScalarTypedParams(int commandTimeout, string connectionString, string spName,
|
||
|
DataRow dataRow);
|
||
|
|
||
|
public abstract object ExecuteScalarTypedParams(int commandTimeout, IDbConnection connection, string spName,
|
||
|
DataRow dataRow);
|
||
|
|
||
|
public abstract object ExecuteScalarTypedParams(int commandTimeout, IDbTransaction transaction, string spName,
|
||
|
DataRow dataRow);
|
||
|
|
||
|
#endregion
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
}
|