DbHelperMapper

A mapper class for all the database helper classes. The mapping can be made based on the type of the target RDBMS data provider.

A mapper class for IDbHelper-based implementations. Mappings are keyed by the target RDBMS data provider type. See Database Helper for more information.

Methods

Below is the list of methods.

Name Description
Add Adds a mapping between the IDbHelper and the type of the DbConnection.
Clear Clears all the existing mappings of the database helpers.
Get Gets the existing mapped IDbHelper object based on the type of the DbConnection.
Remove Removes the existing mapped IDbHelper object based on the type of the DbConnection.

Usability

To add a mapping, call the Add() method:

DbHelperMapper.Add<SqlConnection>(new OptimizedSqlServerDbHelper(), true);

An exception is thrown if a mapping already exists and false is passed for the force argument.

To retrieve the mapping, use the Get() method:

var helper = DbHelperMapper.Get<SqlConnection>();

To remove the mapping, use the Remove() method:

DbHelperMapper.Remove<SqlConnection>();