I have an employee object that has a Manager property. Everytime I use NHibernate to populate an employee it also gets the manager. And then it gets that person's manager and then that person's manager and then....etc.
Can I tell it not to load the manager unless it is needed? I want to lazy load the manager information. This is what my mapping file looks like.
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" default-access="property">
<class name="Core.Domain.Employee, Core" table="vwEmployees" mutable="false">
<id name="EmpID" column="EmpID" access="nosetter.camelcase-underscore">
<generator class="identity" />
</id>
<property name="FirstName" column="FirstName" />
<property name="LastName" column="LastName" />
<property name="BusinessTitle" column="BusinessTitle" />
<many-to-one name="ReportsTo" class="Core.Domain.Employee, Core" column="ReportsToID"/>
<bag name="DirectReports" table="vwEmployees" inverse="true" lazy="true">
<key column="ReportsToID" />
<one-to-many class="Core.Domain.Employee, Core" />
</bag>
</class>
</hibernate-mapping>
Thanks for your help,
Daren