使用 FNH 的 Automap 将派生类映射为独立类
基本上,我有一个 ImageMetadata
类和一个派生自 ImageMetadata
的 Image
类。 Image
添加了一个属性:byte[] Content
,它实际上包含二进制数据。
我想做的是将这两个类映射到 one 表上,但我绝对不需要 NHibernates 的继承支持来启动。我想定制 FNH Automap 来生成类似的内容:
<class name="ImageMetadata" ...>
<property name="Name" ... />
< ... />
<class name="Image" ...>
<property name="Name" ... />
<property name="Content" ... />
< ... />
Is this at一切都可能吗?
目前我有:
Override<ImageMetadata>(m => m.Table("Image"))
但这仍然向 ImageMetatada
的映射添加
元素。
Basically, I have an ImageMetadata
class and an Image
class, which derives from ImageMetadata
. Image
adds one property: byte[] Content
, which actually contains binary data.
What I want to do is to map these two classes onto one table, but I absolutely do not need NHibernates' inheritance support to kick in. I want to tailor FNH Automap to produce something like:
<class name="ImageMetadata" ...>
<property name="Name" ... />
< ... />
<class name="Image" ...>
<property name="Name" ... />
<property name="Content" ... />
< ... />
Is this at all possible?
Currently I have:
Override<ImageMetadata>(m => m.Table("Image"))
but that still adds a <joined-subclass>
element to ImageMetatada
's mapping.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不完全确定,但我认为您需要更改子类化策略。它默认为每个子类一个表,而我认为您想要的是每个层次结构一个表。
我是这样想的:
当然,你必须包含一个鉴别器,这可能不是你想要的。也许有更多 FNH 经验的人可以给出更好的答案。
另请参阅这篇文章,它处理类似的问题。
I'm not entirely sure, but I think you will need to alter the subclassing strategy. It defaults to table per subclass, whereas what I think you want is table per hierachy.
I think like this:
Of course, you will have to include a descriminator then, which might not be what you want. Probably someone with more FNH experience can give a much better answer.
Also see this post, which deals with a similar problem.