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 are the methods available from this class.

  • Add - adds a property attributes mapping into a property.
  • Clear - clears all the existing property attribute mappings.
  • Get - gets the existing mapped property attributes of the property.
  • Remove - removes 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);