title: Mapping properties with custom attributes
body: <p>I want to map two entities with different property name in each entity. I'm mapping ViewModel Entity to Entity framework entity. Is there any out of box feature to add some custom attributes to my viewmodel entity proerties, instead of doing one to one mapping for properties with different property names?. Please find the sample below...</p>
  
  
  
  <pre class="lang-cs prettyprint-override"><code>public class FooModel
  {
      [customAttribute("FooId")]
      public int Id{ get; set; }
      [customAttribute("FooName")]
      public string Name{ get; set; }
  }
  
  public class Foo
  {
      public int FooId{ get; set; }
      public string FooName{ get; set; }
  }
  </code></pre>
  
  <p>i want to map customattribute names with actual property name on the Foo class. I don't want to map explicitly since i have numerous classes in my application.</p>
  
  <p>I am using the folowing extension method, but I don't know how to map destination property dynamically in <code>MapFrom</code></p>
  
  <pre class="lang-cs prettyprint-override"><code>public static IMappingExpression&lt;TSource, TDestination&gt; CustomMapper&lt;TSource, TDestination&gt;
      (this IMappingExpression&lt;TSource, TDestination&gt; expression)
  {
      var flags = BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance;
      var sourceType = typeof(TSource);
      var destinationProperties = typeof(TDestination).GetProperties(flags);
  
      foreach (var property in destinationProperties)
      {
          var props = sourceType.GetProperties();
         // props.Select(s=&gt;s.GetCustomAttributes(typeof(PropertyMapper)).Single(m=&gt;m.)
          foreach (var prop in props)
          {
              var attributes = Attribute.GetCustomAttributes(prop);
              if (attributes.Count() == 1 &amp;&amp; ((PropertyMapper)attributes[0]).Name == property.Name)
              {
           //  expression.ForMember(property.Name,s=&gt;s.MapFrom&lt;TDestination&gt;(t=&gt;t.));
              }
  
          }
  
          if (sourceType.GetProperty(property.Name, flags) == null)
          {
  
              expression.ForMember(property.Name, opt =&gt; opt.Ignore());
          }
      }
      return expression;
  }
  </code></pre>