AutoMapper 可以很方便完成数据对象之间的转换。

Dto -> Entity

Entity -> ViewModel

 

Step 1:通过 NuGet 安装 AutoMapper 的包。

.net core 3.1 WebAPi 使用 AutoMapper 9.0、10.0

 

 

 

.net core 3.1 WebAPi 使用 AutoMapper 9.0、10.0
<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="AutoMapper" Version="9.0.0" />
    <PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="7.0.0" />
  </ItemGroup>


</Project>
Project.csproj

相关文章:

  • 2021-09-05
  • 2022-12-23
  • 2022-12-23
  • 2022-01-23
  • 2021-08-31
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-05-30
  • 2021-12-09
相关资源
相似解决方案