Automapper - want case sensitive

后端 未结 2 747
轮回少年
轮回少年 2021-02-15 15:48

From similar questions on here I have read here that AutoMapper used to be case sensitive, but is now case insensitive. I want it case sensitive - can\'t see any wa

2条回答
  •  离开以前
    2021-02-15 15:57

    The closes thing I could find is the the naming convention configurations: https://github.com/AutoMapper/AutoMapper/wiki/Configuration#naming-conventions

    At the Profile or Mapper level you can specify the source and destination naming conventions:

    Mapper.Initialize(cfg => {
      cfg.SourceMemberNamingConvention = new LowerUnderscoreNamingConvention();
      cfg.DestinationMemberNamingConvention = new PascalCaseNamingConvention();
    });
    

    Or:

    public class OrganizationProfile : Profile 
    {
      public OrganizationProfile() 
      {
        SourceMemberNamingConvention = new LowerUnderscoreNamingConvention();
        DestinationMemberNamingConvention = new PascalCaseNamingConvention();
        //Put your CreateMap... Etc.. here
      }
    }
    

提交回复
热议问题