Link Search Menu Expand Document


A cacher class for the System.Reflection.PropertyInfo. Underneath, it uses the PropertyMapper class to extract the results and caching it for future use.

You should rely on this class rather than using the nameof(Class.Property) of C# when working against the property name.


Below are the methods available from this class.

FlushAllows you to flush the caches.
GetReturns the mapped name of the property.


You can simply call the Get() method of this class by passing the instance of System.Reflection.PropertyInfo.

var properties = PropertyCache.Get<Person>();
    .ForEach(p =>
        var mappedName = PropertyMappedNameCache.Get(p.PropertyInfo);
        // Use the 'mappedName' here

Or via expression.

var mappedName = PropertyCache.Get<Person>(e => e.FirstName);
// Use the 'mappedName' here

The extraction is first checking the presence of the Map attribute and extract the name-mapping from there, then checks the implicit-mapping, otherwise, it will use the PropertyInfo.Name of the System.Reflection.