Nhibernate mapping: fixed count multiple members instead of collection
- by AhmetC
I don't want to put wheels into a collection. How can i map kind of relation?
Class Wheel
{
int id;
Car Owner;
}
Class Car
{
int id;
Wheel Wheel1;
Wheel Wheel2;
Wheel Wheel3;
Wheel Wheel4;
}
I tried this but Wheelmap.Owner comes always null :
Class WheelMap : ClassMap<Wheel>
{
Id(x=>x.Id);
References(x=>x.Owner);
}
Class CarMap : ClassMap<Car>
{
Id(x=>x.Id);
References(x=>x.Wheel1).Cascade.All();
References(x=>x.Wheel2).Cascade.All();
References(x=>x.Wheel3).Cascade.All();
References(x=>x.Wheel4).Cascade.All();
}