Here is the relevant part of my model:

And here is the code from my model class:
public static List<DisplayVan> GetVansForSnapshot(HashSet<int> setVanIDs = null) {
using (BeachReachDataEntities objContext = new BeachReachDataEntities()) {
var qryVans = from v in objContext.vans
.Include("school")
.Include("location")
select new DisplayVan {
vanID = v.vanID,
vanName = v.vanName,
phone = v.phone,
capacity = (int)v.capacity,
schoolName = v.school.schoolName,
lastLocationName = v.location.locationName,
statusNote = v.statusNote,
isOffline = (v.isOffline == 1) ? true : false,
isPrayerRoom = (v.isPrayerRoom == 1) ? true : false,
isNotReady = (v.isNotReady == 1) ? true : false,
creationDate = v.creationDate,
modifiedDate = v.modifiedDate,
vanAssignments = (from va in objContext.vanAssignments
from pr in objContext.pickupRequests
where va.vanID == v.vanID
where pr.pickupRequestID == va.pickupRequestID
select va)
};
if (setVanIDs != null && setVanIDs.Count > 0)
return qryVans.Where(v => setVanIDs.Contains(v.vanID)).ToList<DisplayVan>();
else
return qryVans.ToList<DisplayVan>();
}
}
I also tried:
var qryVans = from v in objContext.vans
.Include("school")
.Include("location")
.Include("vanAssignments")
.Include("vanAssignments.pickupRequest")
select new DisplayVan {
vanID = v.vanID,
vanName = v.vanName,
phone = v.phone,
capacity = (int)v.capacity,
schoolName = v.school.schoolName,
lastLocationName = v.location.locationName,
statusNote = v.statusNote,
isOffline = (v.isOffline == 1) ? true : false,
isPrayerRoom = (v.isPrayerRoom == 1) ? true : false,
isNotReady = (v.isNotReady == 1) ? true : false,
creationDate = v.creationDate,
modifiedDate = v.modifiedDate,
vanAssignments = v.vanAssignments
};
Ignore **** properties. I am using a MySQL database that does not support types boolean.
A query must be designed on DisplayVaninstead of an object vanbecause I have some computable properties that I bind to a datagrid.
The problem is that I am trying to access the navigation attribute of an pickupRequestobject vanAssignment. No matter what I do, the property pickupRequest null. Notice I have lazy loading. How to load vanAssignment pickupRequest relation through my request above?
: vanAssignments vanAssignment. , .
Edit
. , , vanAssignment.person.firstName. :
var qryVans = (from v in objContext.vans
select new {
DisplayVan = new DisplayVan {
vanID = v.vanID,
vanName = v.vanName,
phone = v.phone,
capacity = (int)v.capacity,
schoolName = v.school.schoolName,
lastLocationName = v.location.locationName,
statusNote = v.statusNote,
isOffline = (v.isOffline == 1) ? true : false,
isPrayerRoom = (v.isPrayerRoom == 1) ? true : false,
isNotReady = (v.isNotReady == 1) ? true : false,
creationDate = v.creationDate,
modifiedDate = v.modifiedDate,
vanAssignments = v.vanAssignments
},
PickupRequests = v.vanAssignments.Select(va => va.pickupRequest),
People = v.vanAssignments.Select(va => va.pickupRequest.person)
}).ToList().Select(e => e.DisplayVan);
, :
