Automapper可以将平面对象映射到复杂的对象图吗?
Mapper.CreateMap<PersonDto,Person>()
Run Code Online (Sandbox Code Playgroud)
将PersonDto.BirthCertificateFatherName映射到Person.BirthCertificate.FatherName
不,它不能,它以另一种方式做到这一点
Person.BirthCertificate.FatherName to PersonDto.BirthCertificateFatherName
Run Code Online (Sandbox Code Playgroud)
更新:ValueInjecter可以做到这一点:
//unflattening
person.InjectFrom<UnflatLoopValueInjection>(personDto);
//flatenning
personDto.InjectFrom<FlatLoopValueInjection>(person);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
807 次 |
| 最近记录: |