Frederik
Frederik

Reputation: 249

Why is my WCF DataService not loading expanded properties?

I've exposed some entities (EF) through a data service:
- Races
-- Leagues
--- Teams
---- Participants

I retrieve the races through:

proxy.races

To get the nested properties of the races I use the expand method like this:

proxy.Races.Expand("Leagues/Teams/Participants");

I access the web service through a proxy (fiddler) so that I can inspect the result. When I look at the results in fiddler I can clearly see that the nested structure has been loaded correctly but when I inspect the object in Visual Studio the objects/sub-collections are empty. What am I doing wrong?

Upvotes: 3

Views: 906

Answers (1)

Frederik
Frederik

Reputation: 249

I have experimented a bit and were puzzled that the correct data was sent by the server, but not merged properly in the DataService Entity. By setting the MergeOption-property on the proxy-object I could get it to update the entities.

proxy.MergeOption = System.Data.Services.Client.MergeOption.OverwriteChanges;

I hope that this helps others with the same problem :-)

  • Frederik

Upvotes: 3

Related Questions