Automapper: How to leverage a custom INamingConvention?

前端 未结 2 1264
长情又很酷
长情又很酷 2020-12-21 17:22

I am working with a database where the designers really seemed to enjoy capital letters and the underscore key. Since I have a simple ORM, my data models use these names as

2条回答
  •  伪装坚强ぢ
    2020-12-21 17:39

    What about

    public class DATAMODELProfile : Profile
    {
        protected override void Configure()
        {
            Mapper.CreateMap();
            Mapper.CreateMap();
            Mapper.CreateMap()
                .ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.ID))
                .ForMember(dest => dest.FirstName, opt => opt.MapFrom(src => src.FIRST_NAME))
                .ForMember(dest => dest.ChildDataModels, opt => opt.MapFrom(src => src.CHILD_DATAMODELS));
        }
    }
    

提交回复
热议问题