Link Search Menu Expand Document


A mapper class that is being used to map the class property into its equivalent column in the database. This class is used as an alternative to the Map attribute.


Below is the list of methods.

AddAdds a database column name mapping into a property.
ClearClears all the existing database columns mappings.
GetGets the existing mapped database column name of the property.
RemoveRemoves the exising mapped database column name of the property.


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

PropertyMapper.Add<Customer>(c => c.FirstName, "[FName]", true);
PropertyMapper.Add<Customer>(c => c.LastName, "[LName]", true);
PropertyMapper.Add<Customer>(c => c.DateOfBirth, "[DOB]", 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 mappedName = PropertyMapper.Get<Customer>(c => c.FirstName);

Please consider to always use the PropertyMappedNameCache class when extracting the mapped property name.

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

PropertyMapper.Remove<Customer>(c => c.FirstName);