Automapper - want case sensitive

こ雲淡風輕ζ 提交于 2019-12-03 12:52:36
Imran Ali Khan

You can Refer :

DataReaderMapper should create case-insensitive mappings by default

http://automapper.codeplex.com/workitem/6127

you can control this in Mapper.Initialize as the answer AutoMapper: Mapping between a IDataReader and DTO object

another good post with examples on naming convention mappings: http://blog.ac-graphic.net/automapping-c-objects-from-one-naming-convention-to-an-other/

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
  }
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!