I have a EF Model constructed like the following
WorkOrderHeaders
Which has a FK into these parent properties
(Many to One relationships)
WOPriorities
WOStatusTypes
WOPersonnel
Also has these Child collections which are Linked to its PK
(One to Many Relationships)
WOFieldUpdates
WODetails
The One to many collections load correctly but the Many to One navigation properties are null even though lazy loading is enabled (Which means that on first access the loading of these properties should take place ?
The funny part is that this query works for the filter part
var qWO = (from wos in data.WorkOrderHeaders
where wos.cur_guesttype == "IN"
&& (bool)wos.WOStatusType.isOpenStatus
select wos).Count();
But when the object grap is built for the workOrderHeaders entities they are null for this WOStatusType member ?
Right now the DAL is setup as EF 4 Model exposed as a ADO Service to the DOMAIN project which has a service reference to the ADO service... Could that be part of the problem ?
I would try a .Include() to explicitly load these properties, but that is not an option in the intellisense for the ServiceReferenceEntity object - data.WorkOrderHeaders
which is created as such:
Entities3 data = new Entities3(new Uri("http://server-misbo:8080/MIS.Data/WODataService.svc"));
{Edit}
var qWOs = from wos in data.WorkOrderHeaders.Include("WORentalUnit").Include("WOStatusType").Include("WOPriority")
where wos.assigned_to == person.person_id
&& (bool)wos.WOStatusType.isOpenStatus
select wos;
IEnumerable<WorkOrderHeader> myList = qWOs.ToList();
Figured out that I needed to add a reference and using statement for ObjectQuery to get my Include extension method... However, the parent propeties are still null... I have verfied that the FK values in the fields are correct and result in a single record returned from the parent tables ??
You can use the navigation properties like this can't you ?
Thanks Greg