AutoMapper Usage Experience

Source: Internet
Author: User

It has been a long time since I learned about the AutoMapper component, but I have never understood how this thing should be used and what it is used for. After several setbacks, read the information about 5, 6 times, and finally understand the use and principles (please forgive my understanding of poor ability). After all, there is no great God to guide the maze.

Later, when the project is initialized, the conversion relationship needs to be loaded, and if the name is the same, it will be converted automatically. Different names need to be manually added to the control relationship.

1Mapper.initialize (config =2 {3Config. Createmap<models.views.somain, dingdingu8.u8factory.dto.somaindto>()4. Formember (M = m.ccushand, M = m.mapfrom (f =f.ccuspersonphone))5. Formember (M = m.ivouchstate, M = m.mapfrom (f =f.vouchstate));6Config. Createmap<dingdingu8.u8factory.dto.somaindto, models.views.somain>()7. Formember (M = m.vouchstate, M = m.mapfrom (f =f.ivouchstate))8. Formember (M = m.ccuspersonphone, M = m.mapfrom (f =F.ccushand));9}

The actual conversion code is as follows in the usage process

Automapper.mapper.map<dingdingu8.u8factory.dto.somaindto, models.views.somain> (saveSoaminDto);

  

AutoMapper Usage Experience

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.