A mapper class that is used to map a class property to be primary property. This class is used as an alternative to Primary attribute.
Below are the methods available from this class.
Add- adds a primary property mapping into an entity type.
Clear- clears all the classes identity property mappings.
Get- gets the instance of ClassProperty that is mapped as primary key.
Remove- removes the exising mapped primary property of the data entity.
You should use this class if you do not like to use the Primary attribute. Usually, the purpose of the usability is to make sure that the model is attribute-free and is not bound to a specific ORM.
How to Use?
To add a mapping, simply call the
PrimaryMapper.Add<Customer>(c => c.Id, true);
An exception will be thrown if the mapping is already exists and you passed a
falsevalue in the
To get the mapping, use the
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