Link Search Menu Expand Document

DbHelperMapper


A mapper class for the IDbHelper-based class. The mapping can be made based on the type of the target RDBMS data provider. Please visit the Database Helper for more information.

Methods

Below are the methods available from this class.

  • Add - adds a mapping between the IDbHelper and the type of the DbConnection.
  • Clear - clears all the mappings for the database helpers.
  • Get - gets the mapped IDbHelper based on the type of the DbConnection.
  • Remove - removed the mapping between the IDbHelper and the type of the DbConnection.

Use-Cases

You should use this class if you would like to override the default mapping of the library when it comes to database helper.

How to use?

To add a mapping, simply call the Add() method.

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

An exception will be thrown if the mapping is already exists and you passed a false value in the force argument.

To get the mapping, use the Get() method.

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

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

DbHelperMapper.Remove<SqlConnection>();