2

Why this mapping in the example is not map correctly. When I change the suffix CAST to something else (CAST1) it maps correctly. How should I set the mapper to map correctly with the suffix CAST?

public class Class1
{
    public string OBEC { get; set; }
    public string OBEC_CAST { get; set; }
}
public class Class2
{
    public string Obec { get; set; }
    public string ObecCast { get; set; }
}

public void Map()
{
    Class1 c1 = new Class1() { OBEC = "obec", OBEC_CAST = "cast obce" };
    Class2 c2 = Mapper.Map<Class2>(c1);
}

protected void Application_Start()
{
    AreaRegistration.RegisterAllAreas();
    RouteConfig.RegisterRoutes(RouteTable.Routes);

    Mapper.Initialize(cfg =>
    {
      cfg.RecognizePrefixes(new string [0]);
      cfg.RecognizePostfixes(new string[0]);
      cfg.ClearPrefixes();
      cfg.SourceMemberNamingConvention = new LowerUnderscoreNamingConvention();
      cfg.DestinationMemberNamingConvention = new PascalCaseNamingConvention();
      cfg.CreateMap<Class1, Class2>();
    });
}
kubo
  • 492
  • 7
  • 19
  • It looks like an issue in Automapper. I think the best thing you can do is to report this issue to Automapper. – Valerii Sep 25 '17 at 17:42

0 Answers0