Mathieu Hétu
Mathieu Hétu

Reputation: 159

WCF Data services & EF4 CTP5, how to configure default eager loading schemas for queries?

Project: Exposing via OData (Wcf Data services) an Entity Framework ObjectContext configured by code-first approach.

Everything works fine for simple queries and CUD operations. However, I can't see how to configure default schema loading(server side).

IE: If my entity Customer has a collection of Addresses or a one on one relation to an Entity called Manager, how can I configure my ObjectContext so that every queries on Customers would load automatically all the addresses and the manager of the Customers Entities?

I know that on the client-side, the caller can use the query().Expand("path") to eager load data. But, I want to specify it on the server side so that all queries on Customers entities will result as it was the .Include("Addresses") or .Include("Manager") would be configured by default?

Any idea?

The only 'hack' we can think of is an HTTPModule that intercepts GET requests and adds some ?expand=XXX to the URL. This would be my last solution if we cannot find anything better...

Thanks for your help!

Upvotes: 0

Views: 441

Answers (1)

chrisdrobison
chrisdrobison

Reputation: 1323

You could try using a query interceptor.

http://msdn.microsoft.com/en-us/library/dd744837.aspx

Upvotes: 0

Related Questions