Hi.
I'm starting with NHibernate. I need to map 2 tables to 1 entity but
one of the tables is already mapped to another entity.
I coudl ilustrated as follow:

Table Car (Id int identity, model varchar)
Table RacingCar ( id int identity, id_car int, numberInRace int, team
string)

So I got a Car entity and a CarRacing entity.

    public class Car
    {
        private int _id;
        private string _model;

        public int ID
        {
            get { return _id; }
            set { _id= value; }
        }

        public string Model
        {
            get { return _model; }
            set { _model= value; }
        }

    }

    public class CarRacing : Car
    {
        private int _number;
        private string _team;

        public int Number
        {
            get { return _number; }
            set { _number= value; }
        }

        public string Team
        {
            get { return _team; }
            set { _team= value; }
        }
    }

The mapping for Car entity doesn't bring any dificulties. The issue is
how to map CarRacing taking in count the inheritance and the bussines
restrictions.

Creating a Car doesn't create a CarRacing.
Deleting a Car does delete a CarRacing.

Creating a CarRacing does create a Car.
Deleting a CarRacing doesn't delete a Car.
Updating a CarRacing updates Car and CarRacing.

I need some tips or guidance about how to mapp this hierarchy and get
the requested behaviour.

Thanks in advance.

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to