Property | Type | Description | |
---|---|---|---|
_sqlFormatter | Habanero.Base.SqlFormatter |
Property | Type | Description | |
---|---|---|---|
AppendOrderBy | void | ||
CreateCommand | IDbCommand | ||
CreateDataColumns | void | ||
CreateDatabaseConnection | IDbConnection | ||
ExecuteSqlInternal | int |
Method | Description | |
---|---|---|
BeginTransaction ( IDbConnection openConnection ) : IDbTransaction |
Creates a transaction using the IsolationLevel set as the IsolationLevel. If this doesn't work, creates a transaction using the default IsolationLevel. Uses the connection passed in to create the transaction on - this should be open (so use GetOpenConnectionForReading to get the connection first). Override this method to do special transaction creation logic.
|
|
CreateParameterNameGenerator ( ) : IParameterNameGenerator |
Creates an IParameterNameGenerator for this database connection. This is used to create names for parameters added to an ISqlStatement because each database uses a different naming convention for their parameters.
|
|
CreateSqlStatement ( ) : ISqlStatement |
Creates a ISqlStatement initialised with this IDatabaseConnection
|
|
ErrorSafeConnectString ( ) : string |
Returns a connection string with the password removed. This method serves as a secure way of displaying an error message in the case of a connection error, without compromising confidentiality.
|
|
ExecuteRawSql ( string sql ) : int |
Executes a sql command as before, but with the full sql string provided, rather than with a sql statement object
|
|
ExecuteRawSql ( string sql, IDbTransaction transaction ) : int |
Executes a sql command that returns no result set and takes no parameters, using the provided connection. This method can be used effectively where the database vendor supports the execution of several sql statements in one ExecuteNonQuery. However, for database vendors like Microsoft Access and MySql, the sql statements will need to be split up and executed as separate transactions.
|
|
ExecuteRawSqlScalar ( string sql ) : object |
Executes a raw sql statement. BEWARE OF SQL INJECTION ATTACKS. Use for hardcoded sql only.
|
|
ExecuteSql ( IEnumerable |
Executes a sql command that returns no result set and takes no parameters, using the provided connection
|
|
ExecuteSql ( IEnumerable |
Executes a collection of sql commands that returns no result set and takes no parameters, using the provided connection. This method can be used effectively where the database vendor supports the execution of several sql statements in one ExecuteNonQuery. However, for database vendors like Microsoft Access and MySql, the sql statements will need to be split up and executed as separate transactions.
|
|
ExecuteSql ( ISqlStatement sql ) : int |
Executes a single sql statement object
|
|
ExecuteStoredProcNonQuery ( string procName, IEnumerable @params ) : int |
Executes a stored proc with the params given.
|
|
ExecuteStoredProcNonQuery ( string procName, IEnumerable @params, int timeout ) : int |
Executes a stored proc with the params given using the timeout length given.
|
|
GetConnection ( ) : IDbConnection |
Returns the first closed connection available or returns a new connection object. Throws an exception and adds a message to the log if there is an error opening a connection.
|
|
GetDataTable ( IDataReader reader ) : |
Returns the DataTable for the DataReader.
|
|
GetDataTable ( IDataReader reader, string dataTableName ) : |
Returns a dataTable with the data from the reader and the columns names and field types set up.
|
|
GetLastAutoIncrementingID ( string tableName, IDbTransaction tran, IDbCommand command ) : long |
Gets the value of the last auto-incrementing number. This called after doing an insert statement so that the inserted auto-number can be retrieved. The table name, current IDbTransaction and IDbCommand are passed in so that they can be used if necessary. Note_, this must be overridden in subclasses to include support for this feature in different databases - otherwise a NotImplementedException will be thrown.
|
|
LoadDataReader ( ISqlStatement selectSql ) : IDataReader |
Loads a data reader
|
|
LoadDataReader ( ISqlStatement selectSql, string strOrderByCriteria ) : IDataReader |
Loads a data reader and specifies an order-by clause
|
|
LoadDataReader ( string selectSql ) : IDataReader |
Loads a data reader with the given raw sql select statement
|
|
LoadDataReader ( string selectSql, IDbTransaction transaction ) : IDataReader |
Loads a data reader with the given raw sql select statement for the specified transaction
|
|
LoadDataTable ( ISqlStatement selectSql, string strSearchCriteria, string strOrderByCriteria ) : |
Loads data from the database into a DataTable object, using the sql statement object provided
|
|
SetTimeoutPeriod ( int timeoutSeconds ) : void |
Set the time-out period in seconds, after which the connection attempt will fail
|
Method | Description | |
---|---|---|
CreateCommand ( IDbConnection dbConnection ) : IDbCommand |
Creates an IDbCommand using the provided IDbConnection. Sets the timout for the command based on what you have set using SetTimeoutPeriod
|
|
DatabaseConnection ( ) : System |
Constructor that initialises a new set of null connections
|
|
DatabaseConnection ( string assemblyName, string className ) : System |
Constructor that allows an assembly name and class name to be specified
|
|
DatabaseConnection ( string assemblyName, string className, string connectString ) : System |
Constructor to initialise the connection with the assembly name, class name and connection string provided
|
|
DoAfterExecute ( |
Executes the necessary after execute logic for a particular SqlStatement.
|
|
GetOpenConnection ( IDbTransaction transaction = null ) : IDbConnection |
Returns an open connection. If a IDbTransaction is provided then the connection for the transaction is used and opened if necessary.
|
|
GetOpenConnectionForReading ( ) : IDbConnection |
Either finds a closed connection and opens and returns it, or creates a new connection and returns that. Throws an exception and adds a message to the log if there is an error opening a connection.
|
|
SetupCommand ( ISqlStatement statement, IDbCommand command, IDbTransaction transaction ) : void |
Sets up an IDbCommand object with the provided statement.
|
|
SetupReadTransaction ( IDbCommand dbCommand ) : void |
Setup the transaction on the connection to be used for read operations. This may be overridden for a specific provider (eg. sqlLite)
|
Method | Description | |
---|---|---|
AppendOrderBy ( ISqlStatement statement, string orderByCriteria ) : void |
Appends an order-by clause to the sql statement. " ORDER BY " is automatically prefixed by this method.
|
|
CreateCommand ( IDbConnection connection, IDbTransaction transaction ) : IDbCommand |
Creates an IDbCommand using the provided IDbConnection. The created command is subscribed to the provided IDbTransaction.
|
|
CreateDataColumns ( IDataRecord reader, |
||
CreateDatabaseConnection ( ) : IDbConnection |
Creates a database connection using the assembly name and class name provided.
|
|
ExecuteSqlInternal ( IEnumerable |
public BeginTransaction ( IDbConnection openConnection ) : IDbTransaction | ||
openConnection | IDbConnection | |
return | IDbTransaction |
protected CreateCommand ( IDbConnection dbConnection ) : IDbCommand | ||
dbConnection | IDbConnection | The connection to create the command with |
return | IDbCommand |
public abstract CreateParameterNameGenerator ( ) : IParameterNameGenerator | ||
return | IParameterNameGenerator |
public CreateSqlStatement ( ) : ISqlStatement | ||
return | ISqlStatement |
protected DatabaseConnection ( string assemblyName, string className ) : System | ||
assemblyName | string | The assembly name |
className | string | The database class name |
return | System |
protected DatabaseConnection ( string assemblyName, string className, string connectString ) : System | ||
assemblyName | string | The assembly name |
className | string | The class name |
connectString | string | The connection string. This can be /// generated by the various GetConnectionString() methods, tailored /// for the appropriate database vendors. |
return | System |
protected DoAfterExecute ( |
||
statement | The |
|
command | IDbCommand | The |
transaction | IDbTransaction | The |
return | void |
public ExecuteRawSql ( string sql ) : int | ||
sql | string | The sql statement as a string |
return | int |
public ExecuteRawSql ( string sql, IDbTransaction transaction ) : int | ||
sql | string | A valid sql statement (typically "insert", /// "update" or "delete") as a string. Note_ that this assumes that the /// sqlCommand is not a stored procedure. |
transaction | IDbTransaction | A valid transaction object in which the /// sql must be executed, or null |
return | int |
public ExecuteRawSqlScalar ( string sql ) : object | ||
sql | string | The sql statement to run as a scalar |
return | object |
public ExecuteSql ( IEnumerable |
||
statements | IEnumerable |
A valid sql statement (typically "insert", /// "update" or "delete"). Note_ that this assumes that the /// sqlCommand is not a stored procedure. |
return | int |
public ExecuteSql ( IEnumerable |
||
statements | IEnumerable |
A valid sql statement object (typically "insert", /// "update" or "delete"). Note_ that this assumes that the /// sqlCommand is not a stored procedure. |
transaction | IDbTransaction | A valid transaction object in which the /// sql must be executed, or null |
return | int |
public ExecuteSql ( ISqlStatement sql ) : int | ||
sql | ISqlStatement | The sql statement object |
return | int |
public ExecuteStoredProcNonQuery ( string procName, IEnumerable @params ) : int | ||
procName | string | The stored proc name |
@params | IEnumerable | |
return | int |
public ExecuteStoredProcNonQuery ( string procName, IEnumerable @params, int timeout ) : int | ||
procName | string | The stored proc name |
@params | IEnumerable | |
timeout | int | The timeout in seconds |
return | int |
public GetDataTable ( IDataReader reader ) : |
||
reader | IDataReader | |
return |
public static GetDataTable ( IDataReader reader, string dataTableName ) : |
||
reader | IDataReader | the Reader that the dataTable will be made from |
dataTableName | string | the name of the DataTable |
return |
public GetLastAutoIncrementingID ( string tableName, IDbTransaction tran, IDbCommand command ) : long | ||
tableName | string | The name of the table inserted into |
tran | IDbTransaction | The current transaction, the one the insert was done in |
command | IDbCommand | The Command the did the insert statement |
return | long |
protected GetOpenConnection ( IDbTransaction transaction = null ) : IDbConnection | ||
transaction | IDbTransaction | The |
return | IDbConnection |
protected GetOpenConnectionForReading ( ) : IDbConnection | ||
return | IDbConnection |
public LoadDataReader ( ISqlStatement selectSql ) : IDataReader | ||
selectSql | ISqlStatement | The sql statement object |
return | IDataReader |
public LoadDataReader ( ISqlStatement selectSql, string strOrderByCriteria ) : IDataReader | ||
selectSql | ISqlStatement | The sql statement object |
strOrderByCriteria | string | A sql order-by clause |
return | IDataReader |
public LoadDataReader ( string selectSql ) : IDataReader | ||
selectSql | string | The sql statement as a string |
return | IDataReader |
public LoadDataReader ( string selectSql, IDbTransaction transaction ) : IDataReader | ||
selectSql | string | The sql statement as a string |
transaction | IDbTransaction | Thransaction that gives the context within which the sql statement should be executed |
return | IDataReader |
public LoadDataTable ( ISqlStatement selectSql, string strSearchCriteria, string strOrderByCriteria ) : |
||
selectSql | ISqlStatement | The sql statement object |
strSearchCriteria | string | The search criteria as a string /// to append |
strOrderByCriteria | string | The order by criteria as a string /// to append |
return |
public SetTimeoutPeriod ( int timeoutSeconds ) : void | ||
timeoutSeconds | int | The time-out period in seconds |
return | void |
protected SetupCommand ( ISqlStatement statement, IDbCommand command, IDbTransaction transaction ) : void | ||
statement | ISqlStatement | The |
command | IDbCommand | The |
transaction | IDbTransaction | The |
return | void |
protected SetupReadTransaction ( IDbCommand dbCommand ) : void | ||
dbCommand | IDbCommand | The connection to be set up with a transaction |
return | void |