I can’t seem to access parent child child child. IE. WorkOrder has 1 Unit which has 1 Building which has 1 Site
I’ve been able to eager load the unit, but I can’t seem to get any “deeper”.
Code:
int workOrderId = 1;
var workOrder = context.WorkOrders.Expand("Unit").Where(w => w.Id == workOrderId).First();
string siteId = workOrder.Unit.Building.Site.Id.ToString(); // kaboom (null)
In theory I could eager load the WorkOrder unit, do the same with unit/building and then 1 more time with building to site. But that seems way overboard for what I’m trying to do.
I guess what I want to be able to do is expand all of the children in 1 query.
Any thoughts?
So here’s what I’ve found:
First off, WCF Data Services does not support lazy loading proof. This means that this code will never work:
Then I thought I could use a join like below, however WCF Data Services does not support joins proof:
Finally, after taking a look at the oData specification of expand oData expand I was able to find that my original Expand usage was CLOSE to what I wanted, this works: