Click here to Skip to main content
15,886,661 members
Articles / All Topics

Understanding OData in the Simplest Way

Rate me:
Please Sign up or sign in to vote.
5.00/5 (2 votes)
11 Nov 2015CPOL3 min read 10K  
Understanding OData in the simplest way

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 extension of Atom Publishing Protocol – AtomPub. OData has provisions to fulfill any custom needs of RESTful APIs for extensions.

In simple words, the 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 a 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.

More Articles You Might Also Be Interested In

The post Understanding OData in simplest way appeared first on WCF Tutorial.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Emaratech
United Arab Emirates United Arab Emirates
Imran Abdul Ghani has more than 10 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 WCF Tutorials, Web Development, SharePoint for Dummies.

Comments and Discussions

 
-- There are no messages in this forum --