I'm new at C# and nhibernate, so please bear with me. What I have is two tables (Awards and Conditions) with a many-to-many relationship. Conditions has a column called "Type" that I would like to use to determine the correct inherited class to instantiate for each record in the Conditions Table. DateConditon, RangeCondition, ValueCondition all inherit a base conditions class. Can anyone explain how this is set up or point me in the right direction? The relevant part of my hbm.xml is bellow.
Code:
<class name="PromotionManager.Award, PromotionManager" table="Awards">
<id name="Id" column="Id" type="int">
<generator class="assigned" />
</id>
<property name="ShortName" column="ShortName" type="String" length="25"/>
<property name="LongName" column="LongName" type="String" length="50"/>
<property name="Description" column="Description" type="String" length="100"/>
<property name="IsEnabled" column="IsEnabled" type="Boolean"/>
<property name="ModifiedBy" column="ModifiedBy" type="int"/>
<property name="ModifiedDate" column="ModifiedDate" type="DateTime"/>
<bag name="Conditions" table="AwardsConditions" inverse="true" cascade="all" outer-join="true">
<key column="AwardId" />
<many-to-many column="ConditionId" class="PromotionManager.Condition, PromotionManager" />
</bag>
</class>
<class name="PromotionManager.Condition, PromotionManager" table="Conditions">
<id name="Id" column="Id" type="int">
<generator class="assigned" />
</id>
<property name="ShortName" column="ShortName" type="String" length="25"/>
<property name="LongName" column="LongName" type="String" length="50"/>
<property name="Description" column="Description" type="String" length="100"/>
<property name="Type" column="Type" type="String" length="10"/>
<property name="Definition" column="Definition" type="StringClob" length="100"/>
<property name="IsEnabled" column="IsEnabled" type="Boolean"/>
<property name="ModifiedBy" column="ModifiedBy" type="int"/>
<property name="ModifiedDate" column="ModifiedDate" type="DateTime"/>
<bag name="Awards" table="AwardsConditions" inverse="false" cascade="all" outer-join="true">
<key column="ConditionId" />
<many-to-many column="AwardId" class="PromotionManager.Award, PromotionManager" />
</bag>
</class>