Eddie, can you give some more information on what real life concept
the RacingCar captures?

/Oskar


2010/6/8 Julian <[email protected]>:
> When you use inheritance you should usually have an 'is a'
> relationship. For example, a TextBox inherits from Control because a
> TextBox 'is a' type/kind of Control. The properties on your RacingCar
> would suggest it is not a type of Car; perhaps it is a Team which has
> a collection of Cars? This changes the mapping altogether - and makes
> it much simpler than what you are trying to achieve.
>
> public class Team
> {
>  public string Name { get; set; }
>  public List<Car> Cars { get; set; }
> }
>
> Number of cars is: Team.Cars.Count
>
> On Jun 8, 3:56 am, Eddie <[email protected]> wrote:
>> 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.
>
>

-- 
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