Search code examples
c#automapperdtoautomapper-3

Map dto to complex entity


How can I map the complex UploadDTO to the entity Number?

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; }
}

UPDATE

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

Problem is that the UploadDTO mapping is missing so it does not work. But how can I say:"take UploadDTO.Customer TO Customer for example?"


Solution

  • Just add the missing mapping from UploadDTO to Number:

    Mapper.CreateMap<UploadDTO , Number>();