OData Pros and Cons
OData is the Open Data Protocol. It is an open web protocol started by Microsoft to expose data using existing web technologies. This is based on Representational State Transfer (REST) full architecture. HTTP, AtomPub (similar to RSS, but specifically introduced special XML format for OData), JSON are all supported.
Here, the URL is the primary operator on the data query.
WCF OData Service
In Visual Studio 2013, there is a template to create a WCF OData service. So, we can easily create an OData Service using Visual Studio 2010.
Example of OData Service has been used
- Last (2010) football world cup (S.A), the scoring website was done using an OData Service.
Why should we use an OData Service?
- OData is based on the REST architecture, so we can retrieve data based on an URL.
- It also supports HTTP, Atom Pub as well as JSON format.
- It has support for any type of data source. Even you can use a custom class as a data source.
- No need to create a proxy service object. So, it is lightweight to use.
- You can create your own custom methods and expose it.
- Since it is lightweight, the interaction between server and client is fast. Thus, performance is good.
- It offers full CRUD support by using the different HTTP methods:
- GET: Gets one or many entries.
- POST: Create a new entry.
- PUT: Update an existing entry.
- DELETE: Remove an entry.
- A WCF Data service can expose an entity model via an URI.
- A WCF Data service could be consumed by any type of client like Windows, SilverLight, Web, AJAX and console.
Limitations
- Since it is purely URL based, it is less secure.
- Not every query operator in LINQ is available in OData like Filter, Skip, Take etc.
Working of a WCF Data Service
There are five components.
- DataBase.
- Data Access layer using ADO.Net Entity model or LINQ.
- Entity Model Implementing Iqueryable and Iupdatable Interface.
- WCF Data Service exposing CRUD Operations on entity model as REST Service.
- Consuming it on various types of clients.
Supported Message Format
- JSON
- XML (ATOM)