Simple example
New= mapper.dynamicmap<fileentity> (model);
AutoMapper is a mapping tool based on object-to-object conventions, often used (but not limited to) to turn complex object models into DTOs, typically for viewmodel patterns and cross-service categories.
AutoMapper provides users with a convenient configuration API, just like using conventions to accomplish automatic mapping.
AutoMapper includes the following features:
Spreading
Projection
Configuration verification
Lists and arrays
Nested mappings
Custom type Conversion Program
Custom Value Conversion Program
Custom Value Format Program
Null value substitution
The AutoMapper is a one-way mapper. This means that it does not have an built-in mapping object that supports writing back and forth to the original source unless the user explicitly creates reverse reflection after updating the mapped object. This needs to be done by design, because having a dto write back to, say, a domain model or something, changes its durability and is considered anti-pattern. In this solution, command messages tend to be better choices in bidirectional mapping. However, in some specific environments, one might justify a bidirectional mapping, such as a very simple crud application. A framework that supports bidirectional mapping is glue.
Several common usage scenarios:
-
An external service interface that transforms the entity of the logic layer into the field required by the service consumer.
-
The UI presentation layer transforms the business object into a field that the UI needs to expose.
-
The user's input and output, the DTO and the domain model of the cross-turn.
Reference article:
Http://www.cnblogs.com/mushroom/p/4291975.html
Http://www.cnblogs.com/youring2/p/automapper.html
Http://www.cnblogs.com/1-2-3/p/AutoMapper-Best-Practice.html
AutoMapper Object Mappings