Santyy
Santyy

Reputation: 176

How to use OData in Asp.Net Core

I have been trying to use OData with Dot Net Core, but wasn't successful in doing so. I feel this hasn't been port to the same (I may be wrong here). In this case, is there any alternatives to OData in .Net Core?

Any suggestions are welcome.

Upvotes: 4

Views: 3113

Answers (1)

Iustinian Andrioaie
Iustinian Andrioaie

Reputation: 144

You can install the latest AspNetCore.Odata nugget package and start from there:

https://www.nuget.org/packages/Microsoft.AspNetCore.OData/

In your Startup.cs class make sure that you configure your services to use OData:

 public void ConfigureServices(IServiceCollection services)
    {

        services.AddOData();
        services.AddMvc();
    }

Also, in the Configure method make sure to map the Odata Service Route:

 app.UseMvc(routes =>
        {
            routes.Count().Filter().OrderBy().Expand().MaxTop(null);
            routes.MapODataServiceRoute("odata", "odata", builder.GetEdmModel());
            routes.EnableDependencyInjection();
        });

Upvotes: 2

Related Questions