Automapper - 为什么要用Mapper.Initialize? [英] Automapper - why use Mapper.Initialize?
问题描述
我通常不会问这样的问题就在这里,但遗憾的是虽然 AutoMapper 似乎是一个很好的映射库,它的文档可悲的糟糕 - 没有为库的方法没有XML文档,最官方的在线文档我能找到的这,该非常活跃。如果任何人有任何更好的文档,请让我知道
I wouldn't normally ask this kind of question on here, but unfortunately whilst AutoMapper seems to be a good mapping library, its documentation is woefully bad - there is no XML documentation for the library's methods, and the most official online documentation I could find was this, which is very brisk. If anyone has any better documentation, please let me know.
这是说,这里的问题:为什么要使用 Mapper.Initialize
?它似乎并不如你可以用它来要求 Mapper.CreateMap
立即,并没有文件我不知道是什么初始化
是为了做。
That said, here's the question: why use Mapper.Initialize
? It doesn't seem to be required as you can just use Mapper.CreateMap
immediately, and as there is no documentation I have no clue what Initialize
is meant to do.
推荐答案
我问AutoMapper的用户列表中,并且这个答案基本上是说为什么
I asked on the AutoMapper users list, and this answer basically says why:
的https:/ /groups.google.com/forum/?fromgroups=#!topic/automapper-users/0RgIjrKi28U
这件事情做让AutoMapper做确定性(随机)优化。性能方面,它是更好地得到在初始化
调用创建了所有的映射。
It's something to do with allowing AutoMapper to do deterministic (stochastic) optimization. Performance-wise, it's better to get all your mappings created in the Initialize
call.
这篇关于Automapper - 为什么要用Mapper.Initialize?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!