AspNETCore Odata Batching
Asked Answered
D

1

6

I'm having some issues trying to configure batching for OData on an AspNETCore Web Application. I've searched everywhere (almost) and couldn't find a proper answer. I'm not sure that the current AspNetCore.Odata version 7.0.0 which is still beta has support for batching.

As far as I am concerned, configuring batching seems impossible now since the MapODataServiceRoute method (from the AspNetCore assemply) doesn't seem to receive any ODataBatchHandler as in .NET common Odata.

app.UseMvc(routes =>
    {
        routes.Count().Filter().OrderBy().Expand().MaxTop(null);
        routes.MapODataServiceRoute("odata", "odata", builder.GetEdmModel()); //Doesn't receive any ODataBatchHandler
        routes.EnableDependencyInjection();
});

If someone came across this batching issue for Odata core, some advice would be pretty helpful. Thanks!

Domitian answered 22/2, 2018 at 14:8 Comment(2)
I have this problem too. Did you manage to solve it?Haver
Not yet. As far as my research went, ODATA was not fully supported at that time so I chose to implement simple REST requests for the time. ODATA would have been nice, but I could work around it.Domitian
C
1

Try replace the existing ConfigureServices and Configure methods with the following code:

public void ConfigureServices(IServiceCollection services)
{
    services.AddMvc();
    services.AddOData();
}

public void Configure(IApplicationBuilder app)
{
    var builder = new ODataConventionModelBuilder(app.ApplicationServices);

    builder.EntitySet<Product>("Products");

app.UseMvc(routeBuilder =>
    {
        routeBuilder.Select().Expand().Filter().OrderBy().MaxTop(100).Count();

        routeBuilder.MapODataServiceRoute("ODataRoute", "odata", builder.GetEdmModel());

         routeBuilder.EnableDependencyInjection();
    });
}
Cassella answered 22/11, 2018 at 7:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.