When I first saw the WCF OData Service template in Visual Studio 2010, really I thought, what is the need for OData Services. Because we already have Web Services, WCF Services and REST Services.
But then I was able to understand why when I went through the OData concept.
In this article, I would like to explain the concept of OData. Before starting coding, first I will look into the basics of OData.
What is OData?
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 2010, 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.
- As per my observation, not every query operator in LINQ is available in OData like Filter, Skip, Take, etc.
Where is it suitable to use it?
- The case in which performance is more important than security. For example, as I said before it was used in the 2010 Football World Cup scoreboard.
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



Akash GaurPosted Feb 17, 2012, 3:33 AM
hi arvind.you have explained about WCF OData service very well .thanx for sharing this article .
Stephen JohnsonPosted Feb 17, 2012, 3:15 AM
Its a very nice and useful article.
James LerdorfPosted Feb 17, 2012, 3:15 AM
Really thanks for this great article, it is a very useful stuff.
Aaron CronjePosted Feb 17, 2012, 3:15 AM
Good Work..
Laura ParkerPosted Feb 17, 2012, 3:14 AM
This is good to know about this protocol. Its new to me.