将dto映射到复杂的实体

时间:2015-05-22 14:48:59

标签: c# automapper dto automapper-3

如何将复杂的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映射,因此它不起作用。但是我怎么能说:“以上传DigD。客户为例?”

1 个答案:

答案 0 :(得分:0)

只需将UploadDTO中缺少的映射添加到Number:

Mapper.CreateMap<UploadDTO , Number>();