将 dto 映射到复杂实体

Map dto to complex entity

如何将复杂的 UploadDTO 映射到实体编号?

public class UploadDTO
{
    public CustomerDTO Customer { get; set; }
    public MachineDTO Machine { get; set; }
    public NumberDTO Number { get; set; }
}

public class Number
{
    public Customer Customer { get; set; }
    public Machine Machine { get; set; }
}

更新

Mapper.CreateMap<CustomerDTO , Customer >();
 Mapper.CreateMap<MachineDTO , Machine >();
 Mapper.CreateMap<NumberDTO , Number>();

问题是缺少 UploadDTO 映射,所以它不起作用。但是怎么说呢:"take UploadDTO.Customer TO Customer for example?"

只需添加从 UploadDTO 到 Number 的缺失映射:

Mapper.CreateMap<UploadDTO , Number>();