Mappings
Automapper library is used to automatically map Model to Model, Model to Entity, etc. Mappings are defined in files with MapperConfigurator suffix, which are usually located near mapped type.
Mapping example:
CreateMap<RecordModel, RecordEditorProjection>();
CreateMap<RecordEditorProjection, RecordModel>();
Usually, a developer needs just to define the mapping itself, without child property mappings, because framework contains a lot of mapping extensions:
-
ICreateMapsFromAssembliesProfile - creates additional mappings from existing mappings.
-
ICreateMapsFromTypePairsProfile - scans provided assemblies for certain types and creates additional mappings.
-
ICreateTypePairsFromGenericsProfile - creates additional mappings from generic types.
-
IExtendExistingMapsProfile - extends existing mappings with additional functionality.