C# AutoMapper小demo
2021-06-16 本文已影响0人
stack
1.Install-Package AutoMapper -Source https://www.myget.org/F/automapperdev/api/v3/index.json -IncludePrerelease安装automapper安装包到本项目中
2.配置automapper转换类的configuration文件,采用profile的方式
![](https://img.haomeiwen.com/i4171186/652177538dd54eba.png)
![](https://img.haomeiwen.com/i4171186/d28b4224ff85a109.png)
3.配置文件到项目中,让profile文件能够自动加载,添加配置文件的方式有两种
1)直接添加到mapper配置文件中
![](https://img.haomeiwen.com/i4171186/4f9e6aa793691198.png)
2)通过自动扫描的方式来读取新的配置文件
![](https://img.haomeiwen.com/i4171186/8ec555f979d369c7.png)
![](https://img.haomeiwen.com/i4171186/0eb3f96475c0d0d0.png)