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:
<bag name="Inspections" lazy="false" fetch="select" cascade="none" inverse="true">
<key column="VISIT_COUNTER"/>
<one-to-many class="Inspection"/>
</bag>
The mapping file for Inspections contains the following:
<many-to-one name="ParentVisit" class="Visits" column="VISIT_COUNTER" fetch="select" lazy="false"/>
Now within the Visits class file I call an IList of Inspections using the following:
private IList<Inspection> mInspections;
public virtual IList<Inspection> Inspections
{
get { return mInspections; }
set { mInspections = value; }
}
Then within the Inspection class file I have the following:
private int? mUniqueID;
public virtual int? UniqueId
{
get { return mUniqueID; }
set { mUniqueID = value; }
}
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:
ERROR [TestRunnerThread] ADOExceptionReporter [(null)]- The given key was not present in the dictionary.
Could somebody please help me with this as it's taking me ages to work out!