AutoMapper issue

后端 未结 3 439
臣服心动
臣服心动 2020-12-18 07:48

Trying to automap some objects.
Source objects has properties with _ before name, destination objects - have not. Is it possible to implement ONE map creation, that auto

3条回答
  •  别那么骄傲
    2020-12-18 08:15

    For this you could add a custom mapping to solve this particular case:

    Mapper.CreateMap()
       .ForMember( dest => dest.Id, opt => opt.MapFrom( src => src._Id ) )
       .ForMember( dest => dest.Name, opt => opt.MapFrom( src => src._Name ) );
    

提交回复
热议问题