views:

159

answers:

1

I have a Parent/Child object/mapping as follows:

class Parent { int Id; string name; List children; }

<bag name="Children" cascade="all" lazy="false ">
  <key column="ParentId" />
  <one-to-many class="Child" />
</bag>

class Child { int Id; Parent Parent; string Name; }

<many-to-one name="Parent" column="ParentId" />

Ok, I don't want to use the property "Parent Parent" in Child; i want to use "int ParentId". How would I go about mapping that?

Any help is greatly appreciated!

A: 

If you don't want an association, but rather only the ParentId as an int in the Child class, you don't map the association, but instead map the ParentId just as any other property.

If on the other hand you want both, you simple implement the ParentId int property in Child as an derived property (with no mapping) that delegates to Parent.Id.

Martin R-L