PrimaryMapper
A mapper class that is being used to map a class property to be primary property. This class is used as an alternative to the Primary attribute.
Methods
Below is the list of methods.
Name | Description |
---|---|
Add | Adds a primary property mapping into a class. |
Clear | Clears all the exising primary property mappings. |
Get | Gets the existing mapped primary property of the class. |
Remove | Removes the exising mapped primary property of the class. |
Usability
To add a mapping, simply call the Add()
method.
PrimaryMapper.Add<Customer>(c => c.Id, true);
An exception will be thrown if the mapping is already exists and you passed a
false
value in theforce
argument.
To get the mapping, use the Get()
method.
var property = PrimaryMapper.Get<Customer>();
Please consider to always use the PrimaryCache class when extracting the mapped class property primary.
To remove the mapping, use the Remove()
method.
PrimaryMapper.Remove<Customer>();