自动映射器配置 [英] Automapper configuration

查看:91
本文介绍了自动映射器配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在global.asax中的Application_Start()中调用Mapper.Initialize是否足够?还是应该由一些IoC容器来进行生命周期范围的确定?

Is it enought to call Mapper.Initialize in Application_Start() in global.asax or should some IoC container take care of the lifetime scoping ?

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

推荐答案

就足够了.用这种方式初始化Automapper从来没有问题.

Should be enough. I've never had a problem with initializing Automapper this way.

这篇关于自动映射器配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆