ASP.NET Web API Gets OData v4.0 Support, WCF Will Not
ASP.NET Web API 2.2 for OData v4.0 are now available as nightly builds. The team alsoreleased OData core libraries version 6.1 on nuget with several bug fixes and new features, especially increased support for OData v4 spec. However, the MS team suggested that WCF will not get OData v4 specific features.
OData v4.0 and OData JSON Format v4.0 were recently adopted as an OASIS standard. You can read what is new in OData v4.0.
Following are the improvements in both ASP.NET Web API 2.2 and the OData core libraries -
- Protocol and format changes from V3 to V4
- OData attribute routing
- Support for defining functions in OData model and binding them to controller actions
- Model aliasing - allowing different names for types or properties of OData models and CLR Types
- Ability to define which properties of the model can be filtered, sorted, expanded or navigated across
- Support for ETags
- Support for Enums
- Support for $format query string option so client can specify the format
- Singleton support
- Containment support
Known limitations -
- There are many OData v4 featuers that are still not supported - the main focus of the release was feature parity with earlier release along with few new features
- OData core libraries are capable of serializing the OData v4 Atom format but this is not officially supported since Atom specification is not at CS2 stage yet.
On the client side, there is a new package that supports only OData v4.0 - if your client needs to consume both V1-3 and V4 services, then you'll have to use both the new and the old packages in your application.
A somewhat controversial decision is to reduce investments in making WCF a stack for building OData services. This is what the OData Services team had to say -
..we do plan to reduce investment in WCF Data Services as a stack for creating OData services. To mitigate the inconvenience this may cause, we are working on cleaning up the code and making it compatible with OData v4, and will then release that stack as open source. We do not plan to put any significant investment into adding v4-specific features to the WCF DS stack.
The community, however, wants WCF to support OData 4.0. Says Adam -
As our business tier is written in WCF DS, I feel that we have been thrown under the bus on this decision. We have invested so much effort in working around the weaknesses of WCF DS (prop change tracking, performance, containment, hackish T4 support for client proxies, terrible EF6 alpha quality provider, etc) and have been happily awaiting your new v4 release only to find out at this stage that you are abandoning it. Switching to Web API at this point seems like we pay the price for every decision you make. We are a Gold MS Partner.
Others have also requested that for OData v4.0 support in WCF. We can only wait and watch whether Microsoft changes it's decision on this.
You can get started with writing an OData v4.0 service and use the OData Client Code Generator to generate client-side proxy classes.