Link Search Menu Expand Document

IdentityMapper


A mapper class that is being used to map a class property to be an identity property. This class is used as an alternative to the Identity attribute.

Methods

Below is the list of methods.

NameDescription
AddAdds an identity property mapping into a class.
ClearClears all the exising identity property mappings.
GetGets the existing mapped identity property of the class.
RemoveRemoves the exising mapped identity property of the class.

Usability

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

IdentityMapper.Add<Customer>(c => c.Id, 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 property = IdentityMapper.Get<Customer>();

Please consider to always use the IdentityCache class when extracting the mapped class property identity.

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

IdentityMapper.Remove<Customer>();