Your sequence of Include(..) methods is executed against main object being retrieved from context - SystemDetails
, and, of course, it doesn't have UserInfo
in it.
Paths are all-inclusive. Having both includes replaced with single
Include("UserHousing.UserInfo")
will do the trick. Have a look at documentation for Include(string path) method.
PS.
What version of EF are you using?
While updating to EF5 I've found following IQueryable
extension useful:
DbExtensions.Include<T, TProperty> Method (IQueryable<T>,Expression<Func<T, TProperty>>)
http://msdn.microsoft.com/en-us/library/gg671236%28v=vs.103%29.aspx
See the remarks sections, I believe you are dealing with the following scenario:
- To include a reference and then a reference one level down: query.Include(e => e.Level1Reference.Level2Reference).
you should end up with something like this in your query:
from b in context.SystemDetails
.Include(detail => detail.UserHousing.UserInfo) ...