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开发者_如何学Python 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.
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:
AutoMap.AssemblyOf<Entity>()
.Setup(s =>
{
s.SubclassStrategy = t => SubclassStrategy.Subclass;
});
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.
精彩评论