Question

I'm using ASP.NET MVC WebApi as OData service and I want to query this OData service with Jaydata.

Jaydata has a command line util (JaySvcUtil.exe) that downloads the service definition ($metadata) and creates a full featured JayData / JavaScript client environment by generating the necessary boilerplate code.

Web API + Odata is generating this $metadata page: https://gist.github.com/3917081#file_metadata.xml

The WebApiConfig: https://gist.github.com/3917081#file_web_api_config.cs

When i run

JaySvcUtil.exe -m http://odataserver.com:52132/api/$metadata -o Scripts/test.js -n Test.Testing

It will generate this javascript file https://gist.github.com/3917081#file_jaydatafile.js

The problem is in the generated javascript file:

Default.context = new Default.Container( { name:'oData', oDataServiceHost: 'http://servername:52132/api' });

The namespace = "Default" because of the following value in the $metadata page.

Schema Namespace="Default" xmlns="http://schemas.microsoft.com/ado/2009/11/edm"

How can i change this namespace value in the $metadata page or remove it?

Was it helpful?

Solution

It has been supported in odata nightly build. http://aspnetwebstack.codeplex.com/discussions/353867

After you upgrade the package to latest signed build. You can change the namespace on the model builder.

    private static IEdmModel GetEdmModel()
    {
        ODataModelBuilder modelBuilder = new ODataConventionModelBuilder();
        modelBuilder.Namespace = "xxx";
        modelBuilder.EntitySet<ProductionOrder>("ProductionOrders");
        return modelBuilder.GetEdmModel();
    }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top