There is no configuration for eager loading. You always have to call the Include method. For example in a helper method.
return this.Employer.Include(e => e.EmployeeParams);
Question
I have table Employer
and EmployerParam
. Almost needless to say 1 Employer
has 1 to many EmployeeParams
. I want that every time an Employee
is loaded, its EmployeeParams
are included, i.e. eager-loaded.
The only other was I can think of is using a repository method, but that can always be bypassed and the Employer
loaded without Params.
Solution
There is no configuration for eager loading. You always have to call the Include method. For example in a helper method.
return this.Employer.Include(e => e.EmployeeParams);