1
votes

I'm currently working on a small prototype using the Netflix OData api. I would like to always load entities eagerly. In other words, I don't want to "Expand" properties specifically. Rather I would like to just load all the properties of a given entity when that entity is fetched. I'm not asking for design or architectural advice here. I know the implications of doing this. Is there a way to turn on eager loading at the Context level?

Thanks

1
To the best of my knowledge, this isn't possible. I wasn't part of the original discussion, but if there was one it quite likely centered around how easy it would be to DoS an eagerly loaded service. You could use URL rewriting to append an $expand to all of your queries. I also recommend adding a feature request at data.uservoice.com/forums/… and getting people to vote on it if you think it's important. - Mark Stafford - MSFT

1 Answers

2
votes

As Mark noted above, this is not currently possible with any built-in feature of the WCF Data Services. You could inject the $expand into the URL on the client using some code so that it looks like you don't have to do it explicitly though.

The problem with some generic solution is:

  • Turning this on would transmit lot of data, even though the application might not need it.
  • How many levels should this go? Just one, or two, or many. It can't be unlimited since there might be cycles in the entity graph.

You could also modify your client-side classes to lazy load the property on access. There's an API DataServiceContext.LoadProperty, so just call that in the right spot.