-
Notifications
You must be signed in to change notification settings - Fork 704
OData Batching
OData batch operations are meant to execute the same way that other requests do; however, there may be some minor, but crucial differences required in the setup configuration depending on your target platform.
OData batch operations are facilitated by the OData batching middleware in ASP.NET Core. API Versioning also has its own middleware that is automatically registered for you. When combining API Versioning and OData batching, the order of middleware registration becomes important. In order for OData batching to work properly, automatic middleware registration for API Versioning must be disabled and imperatively registered at the appropriate time.
Disable automatic registration of the API Versioning middleware.
services.AddApiVersioning( options => options.RegisterMiddleware = false );
Register the API Versioning middleware after the OData batching middleware.
public void Configure( IApplicationBuilder app, VersionedODataModelBuilder modelBuilder )
{
app.UseODataBatching();
app.UseApiVersioning();
app.UseMvc(
routeBuilder =>
{
var models = modelBuilder.GetEdmModels();
Func<ODataBatchHandler> batchHandlerFactory = () => new DefaultODataBatchHandler();
routeBuilder.MapVersionedODataRoutes( "odata", "api", models, batchHandlerFactory );
} );
}
- Home
- Quick Starts
- Version Format
- Version Discovery
- Version Policies
- How to Version Your Service
- API Versioning with OData
- Configuring Your Application
- Error Responses
- API Documentation
- Extensions and Customizations
- Known Limitations
- FAQ
- Examples