I'm not too familiar with automapper, but it's been thrown on me by our Software Architect for this project.
The concept is complete encapsulation of volatility. Here's a poorly made Diagram
API/Presentation Layer | Request and Response suffixed objects. (ie, ApplicationCreateRequest)
Business Layer | Home of Domain transfer objects, suffixed DTO. (ie, ApplicationCreateDTO)
Database Layer | Home of Resource Access Objects and entities suffixed RAO and Entity (ie, ApplicationEntity, ApplicationCreateRAO)
I need to convert ApplicationCreateRequests to ApplicationCreateDTO's, as well as convert the Requests Nested objects to DTO's as well.
For example:
public class ApplicationCreateRequest
{
public string FirstName { get; set; }
public string LastName { get; set; }
public ContactCreateRequest Contact { get; set; }
public DemographicCreateRequest Demographic { get; set; }
public EducationCreateRequest Education { get; set; }
public WorkCreateRequest Work { get; set; }
}
becomes
public class ApplicationCreateDTO
{
public string FirstName { get; set; }
public string LastName { get; set; }
public ContactCreateDTO Contact { get; set; }
public DemographicCreateDTO Demographic { get; set; }
public EducationCreateDTO Education { get; set; }
public WorkCreateDTO Work { get; set; }
}
The DTO's and Requests have for the most part the same properties.
I've only gotten to work with very basic mappings such as:
CreateMap<ObjectOne, ObjectTwo>();