Mapping between objects
One of the most boring parts of being a programmer is mapping between objects. It is common to need to integrate systems or components that have conceptually similar objects but with different structures.
Models for data are different for different parts of an application. Models that represent data in storage are often called entity models. Models that represent data that must be passed between layers are often called data transfer objects (DTOs). Models that represent only the data that must be presented to a user are often called view models. All these models are likely to have commonalities but different structures.
AutoMapper is a popular package for mapping objects because it has conventions that make the work as easy as possible. For example, if you have a source member called CompanyName
, it will be mapped to a destination member with the name CompanyName
.
AutoMapper’s creator, Jimmy Bogard, has written an article about its...