Navigation properties, DbContext and Expand/Include

    General discussion

  • 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.

    Thursday, January 19, 2012 5:54 AM

All replies