Understanding OData in simplest way

By | November 11, 2015

In computing technology, OData(Open Data Protocol) is a web protocol used to query and update data. OData is based on REST protocol and is helpful in simple and standard view of the data on web even by simplest of the browsers. It is considered best for building and consumption of the RESTful APIs. It is built upon an exetension of Atom Publishing Protocol – AtomPub. OData has provisions to fulfill any custom needs of RESTful APIs for extensions.

In simple words, goal of OData is to make available an efficient and wide access to data; no matter how it is stored. OData Services

This protocol is used for making data services that are based upon HTTP. By using HTTP commands, it makes the requesting and updating of resources easy. This also provides the whole query language straight into the URL as:OData Services

For Example, querying all students with Age greater than 12 as follows:

http://services.school.com/OData/DataService.svc/Students?$filter=age gt 12

OData Query Operator Represents Query
Numeric Comparison
Gt Greater Than /Students?$filter=age gt 8
Ge Greater Than Or Equal /Students?$filter=age ge 8
Lt Less Than /Students?$filter=age lt 12
Le Less Than Or Equal /Students?$filter=age le 12
Logical Comparison
And Logical And /Students?$filter=age le 12 and age gt 8
Or Logical Or /Students?$filter=age le 8 or age gt 12
Not Logical Not /Students?$filter=not endsWith(StudentName, ‘Ahmad’)
Arithmetic Comparison
Add Addition /Students?$filter=marks add 10 lt 30
Sub Subtraction /Students?$filter=marks sub 5 gt 90
Mul Multiplication /Students?$filter=marks mul 2 lt 10
Div Division /Students?$filter=marks div 2 gt 80

The above table is just given for the purpose of basic understanding, but a complete list of OData Query Operators can be found here.

OData Data Model

Entity data model , EDM, that’s the name of abstract data model used by OData services. It does not make it necessity to use a particular data model or implementation. The only important thing that is to be kept in mind, is that the HTTP interface exposed by the service should be consistent with the protocol used by OData.

Entity Container can have multiple Entity Set and each Entity Set can have multiple Entities where an Entity represents a record in a table. An Entity can have Properties (column) and Navigation Properties(used as an association with other Entities.

OData Data Model

The main theme behind OData protocol is to provide REST based protocol to Create, Read, Update and Delete style operations. The specifications of OData define the standardization of typed, CRUD interface for manipulation of data. This is achieved by providing the collection of entries. This facilitates the ease of getting, updating and removing of data entries. You can find a complete practical example of RESTful Service for all CRUD Operations with source code.

This way we see that open data protocol is an application, basically based on Atom and JSON. This is mainly for the CRUD and Typed operations to standardize the queries in a way so that the large number of users can interact with the services well.

Category: OData WCF Data Services WCF RESTful Service Tags: , ,


Imran Abdul Ghani is working as Software Developer(Senior) with extensive knowledge in Web development technologies especially C#, ASP.NET, MVC, WCF, Web API, ADO.NET Entity Framework, jQuery etc. He has several years of experience in designing/developing enterprise level applications. He is Microsoft Certified Solution Developer for .NET (MCSD.NET) since 2005. You can reach his blogging at www.webdevelopmenthelp.net, www.topwcftutorials.net, and www.sharepointfordummies.net.