BaseDbBridge class

A default abstract implementation of the main DB related intefaces Korzh.DbUtils.IDbReader and Korzh.DbUtils.IDbWriter

public abstract class Korzh.DbUtils.BaseDbBridge
    : IDbReader, IDbBridge, IDbWriter

Fields

Type Name Description
DbConnection Connection The database connection
DatasetInfo CurrentSeedingTable The current table we are going to seed with the data.
ILogger Logger The logger

Properties

Type Name Description
String Quote1 Gets the opening quote for SQL identifirs (table/field names, etc).
String Quote2 Gets the closing quote for SQL identifirs (table/field names, etc).

Methods

Type Name Description
void AddParameters(IDbCommand command, IDataRecord record) Adds the parameters to the DB command object according to the current server type.
void CheckConnection() Checks the current connections. Creates it (calls Korzh.DbUtils.BaseDbBridge.CreateConnection(System.String) methods for that) if necessary. Then this method opens the connection if it's closed now.
DbConnection CreateConnection(String connectionString) Creates the connection. This is an abstract method which must be implemented in derived classes
void ExtractDatasetList(IList<DatasetInfo> datasets) Extracts the list of tables for the current DB and saves them to datasets list passed in the parameter.
void FinishSeeding() Finilizes the seeding process.
String GenerateInsertStatement(DatasetInfo table, IDataRecord record) Generates the INSERT statement.
IDbConnection GetConnection() Gets the database connection.
IDataReader GetDataReaderForSql(String sql) Executes the SQL statement passed in the parameter and returns a System.Data.IDataReader object with the result of that execution.
IDataReader GetDataReaderForTable(DatasetInfo table) Creates and returns a System.Data.IDataReader object for some table. This method usually just constructs a correct SQL statement to get the content of some table (like 'SELECT * FROM TableName) and then calls Korzh.DbUtils.BaseDbBridge.GetDataReaderForSql(System.String) function.
IReadOnlyCollection<DatasetInfo> GetDatasets() Gets the list of tables (or other kind of dataset) for the current connection. This method calls Korzh.DbUtils.BaseDbBridge.ExtractDatasetList(System.Collections.Generic.IList) function to actually get the list of tables.
String GetTableFullName(DatasetInfo table) Gets the full name of the table (including schema and all necessary quotes).
void StartSeeding(DatasetInfo table) Starts the seeding process for the specified table
String ToParameterName(String name) Gets a correct name for the parameter.
void TurnOffAutoIncrement() Sends an SQL command which turns off the possibility to set values for IDENTITY (auto-increment) columns for the current table. Must be implemented in derived classes.
void TurnOffConstraints() Sends an SQL command which turns off the constraints for the current table. Must be implemented in derived classes.
void TurnOnAutoIncrement() Sends an SQL command which turns on the possibility to set values for IDENTITY (auto-increment) columns for the current table. Must be implemented in derived classes.
void TurnOnConstraints() Sends an SQL command which turns the constraints on for the current table. Must be implemented in derived classes.
void WriteRecord(IDataRecord record) Writes (adds) a record to the database tables specified previously at Korzh.DbUtils.BaseDbBridge.StartSeeding(Korzh.DbUtils.DatasetInfo) method call.