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
CommandTimeout
The timeout used when executing sql commands with this connection manager. Default is 0 (no timeout)
Declaration
int CommandTimeout { get; set; }
Property Value
Type | Description |
---|---|
int |
Compatibility
Information about compatibility of the current connector
Declaration
string Compatibility { get; }
Property Value
Type | Description |
---|---|
string |
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 |
---|---|
bool |
IsOdbcOrOleDbConnection
Indicates if the current connection manager is used as a OleDb or Odbc Connection.
Declaration
bool IsOdbcOrOleDbConnection { get; }
Property Value
Type | Description |
---|---|
bool |
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 |
---|---|
bool |
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 |
---|---|
int |
MaxParameterSizeBulkCopy
Returns the maximum amount of parameters that can be used for bulk inserts.
Declaration
int MaxParameterSizeBulkCopy { get; }
Property Value
Type | Description |
---|---|
int |
MaxParameterSizeSql
Returns the maximum amount of parameters that can be passed into a sql query.
Declaration
int MaxParameterSizeSql { get; }
Property Value
Type | Description |
---|---|
int |
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 |
---|---|
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 |
---|---|
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 |
---|---|
string |
State
The state of the underlying ADO.NET connection
Declaration
ConnectionState? State { get; }
Property Value
Type | Description |
---|---|
ConnectionState? |
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 |
---|---|
bool |
SupportProcedures
Indicates if the database supports procedures
Declaration
bool SupportProcedures { get; }
Property Value
Type | Description |
---|---|
bool |
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 |
---|---|
bool |
Methods
BeginTransaction()
Will start a transaction with the default isolation level. 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 with the given isolation level (if supported by the target database) 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, params Action<object>[])
Performs a bulk select
Declaration
void BulkSelect(ITableData data, ICollection<string> selectColumnNames, Action beforeRowReadAction, Action afterRowReadAction, params Action<object>[] actions)
Parameters
Type | Name | Description |
---|---|---|
ITableData | data | Batch of data needed for the where condition |
System.Collections.Generic.ICollection<T><string> | selectColumnNames | Column names included in the select |
System.Action | beforeRowReadAction | Action invoked before any data is read |
System.Action | afterRowReadAction | Action invoked after all data is read |
System.Action<T><object>[] | actions | Pass an action for each column |
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<T><string> | setColumnNames | The column names used in the set part of the update statement |
System.Collections.Generic.ICollection<T><string> | joinColumnNames | The column names to join for the update |
CleanUpBulkInsert(string)
Called after the whole bulk insert operation to change back settings made to improve bulk insert performance
Declaration
void CleanUpBulkInsert(string tableName)
Parameters
Type | Name | Description |
---|---|---|
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()
Closes the connection - this will not automatically disconnect from the database server, it will only return the connection to the ADO.NET connection pool for further reuse.
Declaration
void Close()
CloseIfAllowed()
Closes the connection only if leave open is set to false and no transaction or bulk insert is in progress.
Declaration
void CloseIfAllowed()
CommitTransaction()
Commits the current tranasction.
Declaration
void CommitTransaction()
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 |
---|---|---|
string | command | The sql command |
System.Collections.Generic.IEnumerable<T><QueryParameter> | parameterList | The optional list of parameters |
Returns
Type | Description |
---|---|
int | Number of affected rows. |
ExecuteReader(string, IEnumerable<QueryParameter>, int, Action, Action, params Action<object>[])
Executes a query against the database that does return multiple rows in multiple columns
Declaration
void ExecuteReader(string commandText, IEnumerable<QueryParameter> parameterList = null, int limit = 2147483647, Action beforeRowReadAction = null, Action afterRowReadAction = null, params Action<object>[] actions)
Parameters
Type | Name | Description |
---|---|---|
string | commandText | The sql command |
System.Collections.Generic.IEnumerable<T><QueryParameter> | parameterList | The optional list of query parameters |
int | limit | Maximum number of rows to read |
System.Action | beforeRowReadAction | This action is executed before reading the next row |
System.Action | afterRowReadAction | This action is executed after reading a row |
System.Action<T><object>[] | actions | Every column in the result set will call an action with the value of the current row. The order of the columns corresponds with the order of the passed actions. |
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 |
---|---|---|
string | command | The sql command |
System.Collections.Generic.IEnumerable<T><QueryParameter> | parameterList | The optional list of parameters |
Returns
Type | Description |
---|---|
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)
Performs preparations needed to improved performance of a bulk insert operation
Declaration
void PrepareBulkInsert(string tableName)
Parameters
Type | Name | Description |
---|---|---|
string | tableName | Destination table name |
RollbackTransaction()
Rolls the current transaction back.
Declaration
void RollbackTransaction()