user1943020
user1943020

Reputation:

What is the advantage of using OData with Web API?

I am already using the standard WebAPI and returning JSON objects to my client. Now I saw an application that returned OData.

Can someone explain if there is any reason for me to use OData if I do not want to query my data from anything other than my own client running in the browser. Are there advantages that I could get through using OData ?

Upvotes: 18

Views: 19838

Answers (3)

Alex KeySmith
Alex KeySmith

Reputation: 17091

I agree with the answers already posted, but as an additional insight...

You mentioned that:

... if I do not want to query my data from anything other than my own client running in the browser...

You may not wish to run it normally through anything but your own cilent, but using oData you could use other querying tools for debugging. For example LinqPad allows you to use oData endpoints (such as that provided by stackoverflow).

It's probably not a good enough reason to implement oData if you don't have another reason to do so, but it's an added bonus.

Upvotes: 0

Markus
Markus

Reputation: 22421

If you are only using your data in your own browser application, there is only few advantages to use OData in your situation:

  1. OData is able to provide metadata about your service interface that can be used to generate client code to access the service. So if you have lots of client classes that you need to create, this could speed up your process. On the other hand, if you can share your classes between the server and an ASP.NET based client or if you only have a few classes, this might not be relevant in your situation.
  2. Another - bigger - advantage in your situation is the support for generic queries against the service data. OData supports IQueryable so that you can decide on the client side on how to filter the data that the service provides. So you do not have to implement various actions or use query parameters to provide filtered data. This also means that if you need a new filter for your client, it is very likely that you do not have to change the server and can just put up the query on the client side. Possible filters include $filter expressions to filter the data, but also operations like $skip and $top that are useful when paging data. For details on OData and queries, see this link.

For a complete overview about OData and Web API see this link.

Upvotes: 16

Jalpesh Vadgama
Jalpesh Vadgama

Reputation: 14206

Here are few advantages of OData.

  1. OData is a open protocol started by Microsoft is based on Rest Services so we can get data base on URL.
  2. It suppport various protocol like http,atom,pub and also support JSON format.
  3. No need to create proxy classes which we used to do it in web service.
  4. You will able to write your own custom methods.
  5. It is very light weight so the interaction between client and server will be fast compared to web service and other technologies.
  6. Very simple to use.

Here are few reference links.

http://sandippatilprogrammer.wordpress.com/2013/12/03/what-is-odata-advantages-and-disadvantages/

http://geekswithblogs.net/venknar/archive/2010/07/08/introduction-odata.aspx

http://www.zdnet.com/blog/microsoft/why-microsofts-open-data-protocol-matters/12700

Upvotes: 2

Related Questions