ASP.NET.Core中使用AutoMapper
首先需要在NuGet中引用AutoMapper的类库 install-package AutoMapper install-package AutoMapper.Extensions.Microsoft.DependencyInjection 然后创建好要进行转换的类 public class User { public int ID { get; set; } public string Name { get; set; } } public class UserDto { public int ID { get; set; } public string Name { get; set; } } 然后再创建一个标志接口IProfile internal interface IProfile { } 接下来创建一个类来继承AutoMapper的Profile类与实现刚才创建的标志接口IProfile,并且在构造函数中配置关系映射 public class MyProfile: Profile,IProfile { public MyProfile() { CreateMap<...

