Reputation: 167
I have a url filter like: t1?$filter=ID eq 1&$expand=t2/t3/t4/t5/t6.
Now when I run this query as the very first query using the context, I get everything! When I run this same one from another page and it is the second query run after a previous one using the same objectcontext, then the query stops expanding at t3! The object is null even though the objects id is clearly there. The data exists! So there is something really odd here. Note: I am using a singleton objectcontext factory class, so each page instantiates its own object context to use to execute CRUD operations.
Upvotes: 3
Views: 2011
Reputation: 13310
Assuming you're using WCF DS Client library (DataServiceContext and related classes), then this is very likely due to DataServiceContext.MergeOption setting on the client. The default is AppendOnly which means that if an instance of the given entity already exists on the client, the new data comming from the server will not update it (this is to prevent queries overriding possible changes made on the client). You can change the MergeOption to OverwriteChanges and then the server values will be used. (It applies even to navigation properties, that's why the expand doesn't seem to work, but in reality the server does send the data back to the client, but the client drops it).
Upvotes: 10