AspNETCore Odata批处理

时间:2018-02-22 14:08:59

标签: asp.net-core odata batching

我在尝试在AspNETCore Web应用程序上配置OData的批处理时遇到了一些问题。我到处搜索(差不多),找不到合适的答案。我不确定当前仍然是beta的AspNetCore.Odata版本7.0.0是否支持批处理。

就我而言,现在配置批处理似乎是不可能的,因为MapODataServiceRoute方法(来自AspNetCore)似乎没有像.NET公共Odata那样接收任何ODataBatchHandler

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

如果有人遇到Odata核心的这个批处理问题,一些建议会非常有用。谢谢!

1 个答案:

答案 0 :(得分:1)

尝试使用以下代码替换现有的ConfigureServicesConfigure方法:

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();
    });
}