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!

RAM
  • 2,257
  • 2
  • 19
  • 41
  • I have this problem too. Did you manage to solve it? – NickG Jun 06 '18 at 09:48
  • 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. – Iustinian Andrioaie Jun 07 '18 at 10:31

1 Answers1

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();
    });
}
Kousic
  • 2,651
  • 2
  • 10
  • 23