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