Yesterday I`ve asked a question Person -> Details database structure Now I need to make a NHibernate mapping, where the details are lazy loaded.
so my person map is:
<class name="Employee" table="Employee">
<id name="Id" column="EmployeeId">
<generator class="native" />
</id>
<property name="FName" column="FName"/>
<property name="LName" column="LName"/>
<one-to-one class="Contact" name="Contact" property-ref="Employee" constrained="true" lazy="proxy"/>
</class>
My Contact map:
<class name="Contact" table="Contacts" lazy="true">
<id name="Id" column="Id">
<generator class="native"/>
</id>
<property name="PersonalMobilePhone" column="PersonalMobilePhone"/>
<property name="HomeAdress" column="HomeAdress" />
<property name="WorkTelephone" column="WorkTelephone" />
<many-to-one name="Employee" class="Employee" column="EmployeeId" unique="true" />
</class>
When I try to get concrete Employee from Repository, even if I never use my employee.Contact, profiler shows that there was a SELECT from Contacts table. How can I make this lazy?