动态组件流畅自动映射
有谁知道我们如何在 NHibernate 中使用 Fluent Automapping 自动映射动态组件?
我知道我们可以将普通类映射为组件,但无法弄清楚如何使用流畅的自动映射将字典映射为动态组件。
谢谢
Does anyone know how can we automatically map dynamic components using Fluent Automapping in NHibernate?
I know that we can map normal classes as components, but couldn't figure out how to map dictionaries as dynamic-components using fluent automapping.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我们成功地使用了以下方法(使用 FluentNH 1.2.0.712):
这里我们将某些 Enum 的所有成员映射到单独的列,其中所有成员的类型均为 int。现在我正在研究一个场景,我们对动态列使用不同的类型,如下所示:
这也非常有效。
我仍然要弄清楚如何使用
References
而不是Map
来引用具有自己映射的其他类型...更新:
遗憾的是,参考文献的情况更为复杂,请参阅此 Google 网上论坛帖子< /a>.简而言之:
现在就这些了。
We've used the following approach successfully (with FluentNH 1.2.0.712):
Here we've mapped all members of some Enum to separate columns where all of them are of type int. Right now I'm working on a scenario where we use different types for the dynamic columns which looks like this instead:
This also works very well.
What I'm still about to figure out is how to use
References
instead ofMap
for referencing other types that have their own mapping...UPDATE:
The case with References is unfortunately more complicated, please refer to this Google Groups thread. In short:
That's all for now.
我遇到了完全相同的问题。使用流畅的 nHibernate,我们无法映射这个问题,但我自己以某种方式能够解决这个问题。我的解决方案是动态构建 lambda 表达式并将其分配给对象。例如,
让我复制奥利弗引用的网站的一部分:
我们遇到了这个问题,我们需要在映射中对“图片”进行硬编码。但不知何故,经过一些研究,我创建了以下解决方案:
也许会有帮助
I got struggle with exactly the same problem. With fluent nHibernate we cannot map this but on my own I somehow was able to solve this. My solution is to build lambda expression on the fly and the assign this into object. For instance, lets say that:
Let my copy part of the site that Oliver refer:
And we have this problem that we need to hardcode "Picture" in mapping. But somehow after some research I created following solution:
Maybe it would be helpful