我在asp.net C#项目中实现了Auto Mapper,但出现错误:
映射器不包含初始化的定义
我已经尝试过此示例Link Here
我粘贴了我的代码:
namespace NewsWeb.Web.Infrastructure
{
public class AutomapperWebProfile:Profile
{
public AutomapperWebProfile()
{
CreateMap<DistrictDTO, District>().ReverseMap();
}
public static void Run()
{
Mapper.Initialize(a =>
{
a.AddProfile<AutomapperWebProfile>();
});
}
}
}
在我的Golbal.asax.cs文件中:
AutomapperWebProfile.Run();