Navigation properties, DbContext and Expand/Include
-
Thursday, January 19, 2012 5:54 AM
I have an entity model.
I am using DbContext generator to create the entities.
I have a WCF Data Service which exposes these entities.
I have a silverlight project with a service reference to the WCF Data Service.
If, from the silverlight, I use a query like this:
var qry = from l in svc.Locations.Expand("Attractions") select l;I can see a correctly formatted OData query in fiddler however, the Attractions list is not populated in the returned feed.
If I do exactly the same but, instead of using DbContext I use the default entity generator, I again see an identical OData query in fiddler, but the response does include the Attractions.
Every example I have found for DbContext uses Include to load navigation properties instead of Expand. As far as I can tell, Include is not valid in an OData query.
Any ideas why the service doesn't return the "expanded" entities?
Is it something to do with the
this.Configuration.ProxyCreationEnabled = false;
line of code I have in the DbContext sub class on the server?
Any help greatly appreciated.
All Replies
-
Friday, January 27, 2012 2:00 AM
You can ask the question on http://visualstudiogallery.msdn.microsoft.com/7812b04c-db36-4817-8a84-e73c452410a2, as it is a problem with DbContext generator. In addition, even if it is a general OData issue, the correct forum is: http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataservices/threads/.
-
Friday, January 27, 2012 4:53 AM
Thanks for the Reply.
I have already posted this question to the latter forum (did it 2 minutes after posting the Q here)
I shall give the first forum a go too, thankyou.
-
Friday, January 27, 2012 5:23 AM
-
Wednesday, February 01, 2012 5:52 AM
Thankyou for Replying.
However, I'm not using RIA services.
This issue is summed up in this quote:
"the current released version of WCF Data Services does not recognize DbContext
as an Entity Framework provider, so you need to manually provide the base
ObjectContext
class to the data service. "Which I found in this, very helpful, article : http://social.technet.microsoft.com/wiki/contents/articles/5234.aspx

