Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

ASP.NET Core 3.1 OData with Endpoint Routing and Versioning

$
0
0

Hi!

I am creating an ASP.NET Core 3.1 OData project using endpoint routing (it is already supported) and versioning.

While registering my OData route I have not one but two models (`IEdmModel`), which I get from `VersionedODataModelBuilder`, one for each API version (I have two for now).
I am registering the endpoint as this:

endpoints.MapODataRoute("odata", "odata/v{version:apiversion}", models.First());  //or models.First()

The problem is, I need to have an endpoint for each model, otherwise, the endpoint will only have knowledge of one, and the endpoint also needs to take a parameter for the API version.

This is working, in a way, but, as I said, the endpoint will always get the same model, which may not be appropriate (different properties or different functions per version, for example).
In older versions of OData Versioning there was a `MapVersionedODataRoute` extension method which took a collection of models, but it's now gone.

Any ideas on how to achive this?

Thanks!


Viewing all articles
Browse latest Browse all 9386


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>