Home

OData v3 not working

When I connect to my v3 OData service which has a large schema with multiple namespaces, it downloads and displays the schema correctly along with all the relationships, but as soon as I start a query I get the warning message in the Query window:
"The type or namespace name 'Container' does not exist in the namespace 'LINQPad.User' (Press F4 to check imported namespaces)"

This is because the Container is in a namespace - LINQPad.User.WebApplications.Babel.Models.Entities.Container

But LINQPad assumes it's not in a namespace.

Comments

  • From my research it appears as though the WCF client picks the first (non-complex type) schema and places the Container in that namespace (regardless of where the EntityContainer itself appears). So even if the container is defined in the "Default" schema (as mine is), it appears in the schema containing the entities.
  • Have you tried the latest beta? (The beta uses a newer build of the WCF data service assemblies.)
  • Hi Joe, thanks for getting back to me, I can confirm this occurs on v.4.44.02 (Any CPU).

    As mentioned the issue is that WCF places the Container in the first schema namespace in the metadata that contains entities, rather than in the 'Default' namespace, and as such LINQPad cannot find the Container. This behaviour exists in the latest WCF assemblies.
  • OK, I have fixed the issue now.

    I was producing the OData using the latest WebAPI OData RC, unfortunately when it creates containers it doesn't set the "isDefaultContainer" attribute on the primary container.

    By adding the following code after creating the model -

    IEdmEntityContainer container = _edmModel.EntityContainers().First();
    _edmModel.SetIsDefaultEntityContainer(container, true);

    (Where _edmModel is the model) I managed to set the attribute, and everything started working. Hope that helps someone else.
  • @thargy - You've helped me :) I'm finding the documentation for WebAPI and OData is rather lacking but after two days of struggling through I'm almost there. This LINQPad issue was the latest bit - maybe I'll find other OData clients (eg Excel and ODataExplorer) are also happier to deal with my OData service now too.

    Thanks for posting your solution! MUCH APPRECIATED :P
  • 2 days? Wow, you must be incredibly quick! Either that or you're hooking up to EF, I've been hooking up to our own ORM and it's been hell...

    Haven't managed to get ODataExplorer to work, but I can see the tables in Excel.
Sign In or Register to comment.