Automapper可以将平面对象映射到复杂的对象图吗?
Mapper.CreateMap<PersonDto,Person>()
将PersonDto.BirthCertificateFatherName映射到Person.BirthCertificate.FatherName
答案 0 :(得分:3)
不,它不能,它以其他方式做到了
Person.BirthCertificate.FatherName to PersonDto.BirthCertificateFatherName
更新:ValueInjecter可以执行此操作:
//unflattening
person.InjectFrom<UnflatLoopValueInjection>(personDto);
//flatenning
personDto.InjectFrom<FlatLoopValueInjection>(person);