Hi I'm trying to map some tables using Nhibernate and it generally works apart from when it comes to one-to-many classes. I have a Visits table where each visit has many Inspection records.
The mapping file for Visits contains the following:
The mapping file for Inspections contains the following:
Now within the Visits class file I call an IList of Inspections using the following:
Then within the Inspection class file I have the following:
Whenever I step through the code (using Visual Studio 2008) I reach the line set { mUniqueID = value; } within the Inspection class and it falls over with the error:
Could somebody please help me with this as it's taking me ages to work out!
The mapping file for Visits contains the following:
Code:
<bag name="Inspections" lazy="false" fetch="select" cascade="none" inverse="true"> <key column="VISIT_COUNTER"/> <one-to-many class="Inspection"/> </bag>
Code:
<many-to-one name="ParentVisit" class="Visits" column="VISIT_COUNTER" fetch="select" lazy="false"/>
Code:
private IList<Inspection> mInspections;
public virtual IList<Inspection> Inspections
{
get { return mInspections; }
set { mInspections = value; }
}
Code:
private int? mUniqueID;
public virtual int? UniqueId
{
get { return mUniqueID; }
set { mUniqueID = value; }
}
Code:
ERROR [TestRunnerThread] ADOExceptionReporter [(null)]- The given key was not present in the dictionary.