1

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.

Anton Gogolev
  • 113,561
  • 39
  • 200
  • 288
  • Have you got "byte[] Content" automapping? I wanted to do something similar with arrays of floats, but had to define the properties as IList. This automaps without any overrides (after a bug in FNH was fixed), but is proving to be inefficient, so I'm looking for alternatives. – Tom Bushell Apr 23 '10 at 14:50

1 Answers1

1

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.

Community
  • 1
  • 1
UpTheCreek
  • 31,444
  • 34
  • 152
  • 221