AutoMapper Object Mappings

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.