1.安装
2.使用
public class AutoMapperConfigs:Profile
{
/// <summary>
/// 在构造函数中配置映射关系
/// </summary>
public AutoMapperConfigs()
{
//从A=>B
CreateMap<Flower, FlowerRes>();
}
}
在Program中使用:
//注册AutoMapper
builder.Services.AddAutoMapper(typeof(AutoMapperConfigs));
注入: