I have a class Child which does not have a ParentId property but has the required foreign key in the database. I am trying to get the Children using the ParentId using NHibernate but it is throwing an error saying that could not resolve property ParentId.
public class Parent
{
public int ParentId{ get; set; }
public string Name{ get; set; }
}
public class Child
{
public int ChildId{ get; set; }
public string Name{ get; set; }
}
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="SomeAssembly"
namespace="SomeAssembly.SomeNamespace">
<class name="Parent" lazy="false" table="Parents">
<id name="ParentId">
<generator class="native" />
</id>
<property name="Name" />
</class>
<class name="Child" lazy="false" table="Children">
<id name="ChildId">
<generator class="native" />
</id>
<property name="Name" />
</class>
</hibernate-mapping>