Link Search Menu Expand Document

PropertyValueAttributeCache


A cacher class that is being used to retrieve the existing mapped PropertyValueAttribute objects of a property. Underneath, it uses the PropertyValueAttributeMapper class to extract the mappings and caching it for future use.

Methods

Below are the methods available from this class.

Usability

You can simply call the Get() method of this class by passing the type of the class and the name of the property.

var attributes = PropertyValueAttributeCache.Get(typeof(Person), "Name", includeMappings: true);
// Use the 'attributes' here

Or, via a property expression.

var attributes = PropertyValueAttributeCache.Get<Person>(e => e.Name, includeMappings: true);
// Use the 'attributes' here

The argument includeMappings is used if the existing explicit mappings will be included in the extractions. By default, the value is false.