c# - 自动映射器配置

标签 c# automapper

在 global.asax 的 Application_Start() 中调用 Mapper.Initialize 就足够了吗?还是应该由一些 IoC 容器来处理生命周期范围?

protected void Application_Start()
{
     Mapper.Initialize(x=>x.AddProfile(new SomeProfile()));
}

最佳答案

应该够了。我从来没有遇到过以这种方式初始化 Automapper 的问题。

关于c# - 自动映射器配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5537192/

相关文章:

c# - 以编程方式添加 Web 控件时的回发问题

c# - ASP.NET 脚本 "scheduling"问题

c# - 如何加速具有大量数据的服务器绑定(bind)控件的网页

asp.net-mvc - 我在哪里可以在 Orchard 模块中初始化 AutoMapper 映射?

c# - 无法加载 DLL(找不到模块 HRESULT : 0x8007007E)

c# - 为什么在使用结构作为通用字典键时 C# 会产生垃圾?

c# - 使用 AutoMapper 创建一个对象,该对象表示比较两个其他对象的结果

C# automapper 嵌套集合

c# - 方法 'Where' 不能遵循方法 'Select' 或不受支持

asp.net-mvc - 使用 AutoMapper 将对象展平为 int