I am trying to query a single object in a database using DataServiceQuery. The object I'm trying to load is related to the schedule of other objects that I want to load. MSDN describes here and here that I can load my mentioned objects using DataServiceQuery <TElement> .Expand or DataServiceContext.LoadProperty.
This is great for relationships of the first degree of my essence, but I have a problem loading relationships relationships.
Obviously, I could call LoadProperty for all second-degree relationships and iterate over all second-degree collections, but I was hoping I could look forward to loading the entire relationship graph in one query. Is it possible?
Edit
In fact, the loading of a second-degree relationship is not so obvious. The following code does not work (for clarity, the domain model has changed):
var context = DataServiceReference.DataServiceContextFactory.Create();
var customer = (from c in context.Customers.Expand("Orders")
where c.CustomerId.Equals(customerId)
select c).First();
foreach (var order in customer.Orders)
{
context.LoadProperty(order, "Products");
InvalidOperationException is thrown in the last line above: "The context does not currently track the object." I use self-control objects. Could this error be related to STE?
How can I load a second degree relationship in any way?
Editing Solution
It turns out that DataServiceQuery <TElement> .Expand uses a different path syntax compared to ObjectQuery <T> .Include. The former uses a slash as a path separator, the latter uses a period. Can someone explain why the syntax is incompatible, and where can I find the Expand path syntax documentation?
source
share