按约定映射所有实体
我正在通过代码玩 NH 3.2.0 映射。由于我有一个可以按照约定映射所有内容的场景,因此我想将原始实体添加到映射器,然后通过自定义 ModelInspector
加上由 ModelMapper 生成的事件来自定义它们
。不幸的是,ModelMapper 显然不允许我直接添加实体,而是想要实现 IConformistHoldersProvider 的对象,因此我最终以传递空类来为我想要映射的每个实体实现 ClassMapping。有没有一些最聪明的方法来实现同样的目标?
谢谢。
I'm playing with NH 3.2.0 mapping by code. Since I've a scenario in which I can map everithing by convention I would like to add raw entities to the mapper, and then customize them by a custom ModelInspector
plus the event generated by the ModelMapper
. Unfortunately the ModelMapper apparently does not allow me to add entity dirctly, instead he want object implementing IConformistHoldersProvider
, so I eventually end with pass empty classes implementing ClassMapping for each entity I want to map. Is there some smartest way to achieve the same ?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我发现自己,问题是我正在使用
mapper.CompileMappingForAllExplicitlyAddedEntities();
问题根本就不存在......
如果我使用并传递所需的实体,
Well I found myself, problem was that I was using
mapper.CompileMappingForAllExplicitlyAddedEntities();
the problem simply does not sussists if I use
and I pass the required entities...