Using AutoMapper to unflatten a DTO

前端 未结 7 936
执念已碎
执念已碎 2020-11-28 07:52

I\'ve been trying to use AutoMapper to save some time going from my DTOs to my domain objects, but I\'m having trouble configuring the map so that it works, and I\'m beginni

7条回答
  •  [愿得一人]
    2020-11-28 08:36

    This also seems to work for me:

    Mapper.CreateMap();
    Mapper.CreateMap()
            .ForMember(dest => dest.Address, opt => opt.MapFrom( src => src )));
    

    Basically, create a mapping from the dto to both objects, and then use it as the source for the child object.

提交回复
热议问题