Let's say I have two objects I'd like to map:
// Domain objects
public class MyDomainObject
{
public string SimpleText { get; set; }
public int SimpleNumber { get; set; }
public MySubObject ComplexValue { get; set; }
}
public class MySubObject
{
public int Id { get; set; }
public string Name { get; set; }
}
// DTOs
public class MyDto
{
public string SimpleText { get; set; }
public int SimpleNumber { get; set; }
public int ComplexValueId { get; set; }
public string ComplexValueName { get; set; }
}
// Mapping config
Mapper.CreateMap<MyDomainObject, MyDto>();
Ths will work fine without extra configuration because AutoMapper will look at camelcasing and drill down.
Now I'd like to map the DTO back to the domain object:
Mapper.Map<MyDto, MyDomainObject>(dto, domainObj);
What would the best/simplest mapping configuration be to achieve it?