Hi
Iam struggling with NHibernate and its lazyload.
I have a structure which I simplified but it show my issue.
Class Shift {
int ShiftID;
DateTime ShiftStart;
Employee Employee;
}
Class Employee {
int EmployeeID;
string Name;
}
Data:
ShiftData
ID SHIFTTIME EmployeeID (int)
1 12:00 0
2 13:00 1
3 14:00 0
4 13:00 3
Employees
ID NAME
1 Morten
2 Peter
3 Henrik
My loading strategy for the shift is using Join so that when I load the shifts NHibernate automatically does a Left join to get the customer. This works perfectly for the shifts with Employees attached, however some shifts haven’t got any employees yet.
When I try to access the Employee of such a shift once the shift is loaded it results in another SELECT against the database (found out by using your NHProfiler) Why does this happen ?
Hope you have an answer iam really stuck on this.