Interface IConnectionManager
Common properties and methods for all database connection managers
Inherited Members
Namespace: ETLBox.Connection
Assembly: ETLBox.dll
Syntax
public interface IConnectionManager : IDisposable
Properties
ConnectionManagerType
The database type for the connection manager.
Declaration
ConnectionManagerType ConnectionManagerType { get; }
Property Value
Type | Description |
---|---|
ConnectionManagerType |
ConnectionString
The connection string used to establish the connection with the database
Declaration
IDbConnectionString ConnectionString { get; set; }
Property Value
Type | Description |
---|---|
IDbConnectionString |
IsInBulkInsert
Indicates if the current connection is currently used in a bulk insert operation (e.g. performed by a DbDestination)
Declaration
bool IsInBulkInsert { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsOdbcOrOleDbConnection
Indicates if the current connection mangager is used as a OleDb or Odbc Connection.
Declaration
bool IsOdbcOrOleDbConnection { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
LeaveOpen
By default, after every sql operation the underlying ADO.NET connection is closed and retured to the ADO.NET connection pool. (This is the recommended behavior) To keep the connection open and avoid having the connection returned to the pool, set this to true. A connnection will be left open when a bulk insert operation is executed or a transaction hase been openend and not yet commited or rolled back.
Declaration
bool LeaveOpen { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
MaxLoginAttempts
Number of attempts that the connection managers tries to connect before it decides that the database is not reachable.
Declaration
int MaxLoginAttempts { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
MaxParameterAmount
returns the maximum amount of parameters that ca be passed into a sql query.
Declaration
int MaxParameterAmount { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
PP
The character that is used in front of parameter names in query to identify the parameter. All databases use the '@' character, except Oracle which uses ':'
Declaration
string PP { get; }
Property Value
Type | Description |
---|---|
System.String |
QB
The quotation begin character that is used in the database. E.g. SqlServer uses: '[' and Postgres: '"'
Declaration
string QB { get; }
Property Value
Type | Description |
---|---|
System.String |
QE
The quotation end character that is used in the database. E.g. SqlServer uses: ']' and Postgres: '"'
Declaration
string QE { get; }
Property Value
Type | Description |
---|---|
System.String |
State
The state of the underlying ADO.NET connection
Declaration
ConnectionState? State { get; }
Property Value
Type | Description |
---|---|
System.Nullable<System.Data.ConnectionState> |
SupportComputedColumns
Indicates if the database supports computed columns
Declaration
bool SupportComputedColumns { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
SupportDatabases
Indicates if database server does support multiple databases. A database in ETLBox means a schema in MySql.
Declaration
bool SupportDatabases { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
SupportProcedures
Indicates if the database supports procedures
Declaration
bool SupportProcedures { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
SupportSchemas
Indicates if the database supports schemas In MySql, this is false because the schema here is a database in ETLBox. Use SupportDatabases instead
Declaration
bool SupportSchemas { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Transaction
The current transaction. Use BeginTransaction(IsolationLevel) to start a transaction, and CommitTransaction() or RollbackTransaction() to commit or rollback.
Declaration
IDbTransaction Transaction { get; set; }
Property Value
Type | Description |
---|---|
System.Data.IDbTransaction |
Methods
AfterBulkInsert(String)
Called after every bulk insert of a batch
Declaration
void AfterBulkInsert(string tableName)
Parameters
Type | Name | Description |
---|---|---|
System.String | tableName | Destination table name |
BeforeBulkInsert(String)
Called before every bulk insert of a batch
Declaration
void BeforeBulkInsert(string tableName)
Parameters
Type | Name | Description |
---|---|---|
System.String | tableName | Destination table name |
BeginTransaction()
Will start a transaction. This will leave the underlying ADO.NET connection open until the transaction is committed or rolled back.
Declaration
void BeginTransaction()
BeginTransaction(IsolationLevel)
Will start a transaction. This will leave the underlying ADO.NET connection open until the transaction is committed or rolled back.
Declaration
void BeginTransaction(IsolationLevel isolationLevel)
Parameters
Type | Name | Description |
---|---|---|
System.Data.IsolationLevel | isolationLevel | The isolation level for the transaction |
BulkDelete(ITableData)
Performs a bulk delete
Declaration
void BulkDelete(ITableData data)
Parameters
Type | Name | Description |
---|---|---|
ITableData | data | Batch of data |
BulkInsert(ITableData)
Performs a bulk insert
Declaration
void BulkInsert(ITableData data)
Parameters
Type | Name | Description |
---|---|---|
ITableData | data | Batch of data |
BulkSelect(ITableData, ICollection<String>, Action, Action, Action<Object>[])
Declaration
void BulkSelect(ITableData data, ICollection<string> selectColumnNames, Action beforeRowReadAction, Action afterRowReadAction, params Action<object>[] actions)
Parameters
Type | Name | Description |
---|---|---|
ITableData | data | |
System.Collections.Generic.ICollection<System.String> | selectColumnNames | |
System.Action | beforeRowReadAction | |
System.Action | afterRowReadAction | |
System.Action<System.Object>[] | actions |
BulkUpdate(ITableData, ICollection<String>, ICollection<String>)
Performs a bulk update
Declaration
void BulkUpdate(ITableData data, ICollection<string> setColumnNames, ICollection<string> joinColumnNames)
Parameters
Type | Name | Description |
---|---|---|
ITableData | data | Batch of data |
System.Collections.Generic.ICollection<System.String> | setColumnNames | |
System.Collections.Generic.ICollection<System.String> | joinColumnNames |
CheckIfTableOrViewExists(String)
Describes how the connection manager can check if a table or view exists
Declaration
bool CheckIfTableOrViewExists(string objectName)
Parameters
Type | Name | Description |
---|---|---|
System.String | objectName | The formatted table or view name |
Returns
Type | Description |
---|---|
System.Boolean | True if the table or view exists |
CleanUpBulkInsert(String)
Called after the whole bulk insert operation (all batches)
Declaration
void CleanUpBulkInsert(string tableName)
Parameters
Type | Name | Description |
---|---|---|
System.String | tableName | Destination table name |
Clone()
Cretes a clone of the current connection manager
Declaration
IConnectionManager Clone()
Returns
Type | Description |
---|---|
IConnectionManager | A instance copy of the current connection manager |
CloneIfAllowed()
Try to create a clone of the current connection - only possible if LeaveOpen is false.
Declaration
IConnectionManager CloneIfAllowed()
Returns
Type | Description |
---|---|
IConnectionManager | The connection that was either cloned or the current connection |
Close()
Always closes the connection
Declaration
void Close()
CloseIfAllowed()
Closes the connection if leave open is false and no transaction or bulk insert is in progress.
Declaration
void CloseIfAllowed()
CommitTransaction()
Commits the current tranasction.
Declaration
void CommitTransaction()
CreateCommand(String, IEnumerable<QueryParameter>)
Creates a underlying ADO.NET command.
Declaration
IDbCommand CreateCommand(string commandText, IEnumerable<QueryParameter> parameterList)
Parameters
Type | Name | Description |
---|---|---|
System.String | commandText | The command text |
System.Collections.Generic.IEnumerable<QueryParameter> | parameterList | An optional list of parameters for the command |
Returns
Type | Description |
---|---|
System.Data.IDbCommand | The ADO.NET command |
ExecuteNonQuery(String, IEnumerable<QueryParameter>)
Executes a query against the database that doesn't return any data.
Declaration
int ExecuteNonQuery(string command, IEnumerable<QueryParameter> parameterList = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | command | |
System.Collections.Generic.IEnumerable<QueryParameter> | parameterList | The optional list of parameters |
Returns
Type | Description |
---|---|
System.Int32 | Number of affected rows. |
ExecuteReader(String, IEnumerable<QueryParameter>)
Executes a query against the database that does return multiple rows in multiple columns
Declaration
IDataReader ExecuteReader(string command, IEnumerable<QueryParameter> parameterList = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | command | |
System.Collections.Generic.IEnumerable<QueryParameter> | parameterList | The optional list of parameters |
Returns
Type | Description |
---|---|
System.Data.IDataReader | A data reader to iterate through the result set |
ExecuteScalar(String, IEnumerable<QueryParameter>)
Executes a query against the database that does return only one row in one column.
Declaration
object ExecuteScalar(string command, IEnumerable<QueryParameter> parameterList = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | command | |
System.Collections.Generic.IEnumerable<QueryParameter> | parameterList | The optional list of parameters |
Returns
Type | Description |
---|---|
System.Object | The result |
Open()
Opens the connection to the database. Normally you don't have to do this on your own, as all tasks and components will call this method implictly if the connection is closed. If the connection is already open, nothing is done.
Declaration
void Open()
PrepareBulkInsert(String)
Called before the whole bulk insert operation (all batches)
Declaration
void PrepareBulkInsert(string tableName)
Parameters
Type | Name | Description |
---|---|---|
System.String | tableName | Destination table name |
ReadTableDefinition(ObjectNameDescriptor)
Describe how the table meta data can be read from the database
Declaration
TableDefinition ReadTableDefinition(ObjectNameDescriptor TN)
Parameters
Type | Name | Description |
---|---|---|
ObjectNameDescriptor | TN | The formatted table name |
Returns
Type | Description |
---|---|
TableDefinition | The definition of the table, containing column names, types, etc. |
RollbackTransaction()
Rolls the current transaction back.
Declaration
void RollbackTransaction()