R – NHibernate mapping generic classes

nhibernatenhibernate-mappingxml

How does one create a mapping file for a generic class in NHibernate.
Say I have a class Foo
How would it look in the mapping document?
class name="mydll.Foo ???? , mydll" …

I know if it was a Foo it would be:
class name="mydll.Foo`1[[mydll.Fee, mydll]], mydll"

Would it be something like:
class name="mydll.Foo`1[[mydll.Fee, mydll],[mydll.Fi, mydll]], mydll" (I tried this, but it didn't work.

Best Answer

I might be in over my head here (Just started doing NHibernate 3 days ago), but does it give meaning to map an abstract class? You cant instantiate an abstract class, so, why would you map it to data?

My best guess is that you have to map your subclasses to the data they need, and make public / protected setter's on your baseclass, to map these too. This would ofc mean a lot of copy-pasting since youd map your base class the same way for all (in a perfect world) subclasses.

[EDIT] Found this: NHibernate: One base class, several mappings

Related Topic