How can I have odata v3 and v4 api working side by side out on the same project ?
Can the same controller be returning data in both formats ? Do I need to have 2 copies of the same controller - one per Odata version ?
I know this should be possible cause the official WEBAPI page says it's been designed for.
"ASP.NET Web API supports both v3 and v4 of the protocol. You can even have a v4 endpoint that runs side-by-side with a v3 endpoint." - quote from www.asp.net
Question is - how do I do that ? Any tutorials ?
The Open Data Protocol (OData) enables the creation of REST-based data services, which allow resources, identified using Uniform Resource Locators (URLs) and defined in an Entity Data Model (EDM), to be published and edited by Web clients using simple HTTP messages.
The Open Data Protocol (OData) is a data access protocol for the web. OData provides a uniform way to query and manipulate data sets through CRUD operations (create, read, update, and delete). ASP.NET Web API supports both v3 and v4 of the protocol.
OData defines parameters that can be used to modify an OData query. The client sends these parameters in the query string of the request URI. For example, to sort the results, a client uses the $orderby parameter: http://localhost/Products?$orderby=Name. The OData specification calls these parameters query options.
Here is a sample for side by side: https://aspnet.codeplex.com/SourceControl/latest#Samples/WebApi/OData/v4/ODataSxSSample/, FYI. This sample has 2 copies of the same controller.
Yes, you do need two set of controllers. V4 doesn't provide backward compatibility.
There is also another sample for versioning: https://aspnet.codeplex.com/SourceControl/latest#Samples/WebApi/OData/v4/ODataVersioningSample/
This is the right solution for you. You make the first version (~/api/v1/) for OData V3 and the second version (~api/v2/) for V4. It provides better separation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With