views:

62

answers:

1

Hi,

I have what I think should be a fairly simple mapping issue, but not having any luck figuring out what I'm missing to make it work. I'll just jump into a simple example to get to the point of what I'm trying:

//Base user class
public class UserBase : Entity
{
   //properties user class should have
}
//
//Concrete User class (in different assembly)
//
//Item in same assembly as UserBase
public class Item : Entity
{
    public virtual UserBase User { get; set; }
    //other properties etc..
}

So the UserBase class get's implemented and mapped as part of a User class in a different assembly. That is fine, but since I'm not mapping UserBase as it's own mapping, when the mapping tries to run on the Item class it blows up because UserBase isn't mapped.

My question is; Is it possible to tell the Item class to use whatever the concrete class is for UserBase?

I'm using Fluent NHibernate to do my mapping, but I think as long as I can get the right push on how the Mapping file should look I can figure out how to do it in Fluent NHibernate.

Thanks, Bryan

A: 

You will have to create a mapping for UserBase, and also for each and every subclass of UserBase, and specify that these classes are subclasses of UserBase.

There are 3 ways of implementing inheritance in NHibernate. I do not know if Fluent has any documentation about it, but I believe that this article should be helpfull to get you started.

Frederik Gheysels
I'd looked at that once before, but thought there might be a prettier way of doing it. I guess that make sense though.
Bryan Brown