using System;
using System.Data;
namespace EPS.Common.Data
{
///
/// Specifies common methods and properties for working with databases.
///
public interface IDbHelper
{
///
/// Gets the connection string for the database.
///
string ConnectionString { get; }
///
/// Implementing classes should return an open connection to the database.
///
/// An open connection to the database.
IDbConnection GetConnection();
///
/// Gets a connection to the database.
///
/// Initial state of the database connection.
/// A connection to the database.
IDbConnection GetConnection(InitialConnectionStates initialState);
///
/// Executes a query and returns the value in the first column of the first row of the resultset.
///
/// The type of the value returned.
/// The query to execute.
/// The value in the first column of the first row of the resultset.
T ExecuteScalar(string commandText);
///
/// Executes a command a returns the value in the first column of the first row of the resultset.
///
/// The type of the value returned.
/// The command to execute.
/// The value in the first column of the first row of the resultset.
T ExecuteScalar(IDbCommand command);
///
/// Executes the query, and returns an array of values from the first column of all rows in the resultset.
///
/// The type of value in the first column.
/// The query to execute.
/// An array of values from the first column of all rows in the resultset.
TItem[] ExecuteArray(string commandText);
///
/// Executes the command, and returns an array of values from the first column of all rows in the resultset.
///
/// The type of vlaue in the first column.
/// The query to execute.
/// An array of value sfrom the first column of all rows in the resultset.
TItem[] ExecuteArray(IDbCommand command);
///
/// Executes a query and returns the number of rows affected.
///
/// The query to execute.
/// The number of rows affected.
int ExecuteNonQuery(string commandText);
///
/// Executes a command and returns the number of rows affected.
///
/// The command to execute.
/// The number of rows affected.
int ExecuteNonQuery(IDbCommand command);
///
/// Executes a query and returns the results in a datatable.
///
/// The query to execute.
/// A datatable containing the results of executing the query.
DataTable ExecuteDataTable(string commandText);
///
/// Executes a command and returns the results in a datatable.
///
/// The command to execute.
/// A datatable containing the results of executing the command.
DataTable ExecuteDataTable(IDbCommand command);
///
/// Executes a query and returns a data reader containing the results.
///
/// The query to execute.
/// A data reader containing the results of executing the query.
IDataReader ExecuteReader(string commandText);
///
/// Executes a command and returns a data reader containing the results.
///
/// The command to execute.
/// A data reader containing the results of executing the command.
IDataReader ExecuteReader(IDbCommand command);
}
}