ClassMapper
A mapper class for associating a class with its corresponding database object (table or view). This is the programmatic alternative to the Map attribute.
Methods
Below is the list of methods.
| Name | Description |
|---|---|
| Add | Adds a mapping between the class and the name of the database object. |
| Clear | Clears all the existing database object name mappings. |
| Get | Gets the existing mapped database object name of the class. |
| Remove | Removes the exising database object name of the class. |
Usability
To add a mapping, call the Add() method:
ClassMapper.Add<Customer>("[sales].[Customer]", true);
An exception is thrown if a mapping already exists and
falseis passed for theforceargument.
To retrieve the mapping, use the Get() method:
var mappedName = ClassMapper.Get<Customer>();
Always use ClassMappedNameCache when retrieving the mapped class name.
To remove the mapping, use the Remove() method:
ClassMapper.Remove<Customer>();