Link Search Menu Expand Document

PropertyValueAttributeMapper


A mapper class that is being used to map the list PropertyValueAttribute objects into a class property.

Methods

Below is the list of methods.

NameDescription
AddAdds a property attributes mapping into a property.
ClearClears all the existing property attribute mappings.
GetGets the existing mapped property attributes of the property.
RemoveRemoves the exising mapped property attributes of the property.

Usability

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

PropertyValueAttributeMapper.Add<Customer>(c => c.Name, new NameAttribute("CompleteName"));

You can also map multiple instances.

PropertyValueAttributeMapper.Add<Customer>(c => c.Name, new PropertyValueAttribute[]
{
    new NameAttribute("CompleteName"),
    new SizeAttribute("256"),
    new DbTypeAttribute(DbType.NVarChar)
});

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 = PropertyValueAttributeMapper.Get<Customer>(c => c.Name);

Please consider to always use the PropertyValueAttributeCache class when extracting the mapped property attributes.

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

PropertyValueAttributeMapper.Remove<Customer>(c => c.Name);