Tuesday, March 30, 2010

Using Microsoft OData Protocol (formerly Known as ADO.NET Services) to expose our Data.

OData – Open Data Protocol is developed by Microsoft to be an open standard for exposing the data across Internet. This is OData protocol is based on REST and JOSN.

Where OData  protocol is used?

  1. SharePoint 2010 ( ListData.Svc)
  2. Windows Azure
  3. The Project code name Dallas

In Microsoft.NET  we can expose database through OData Protocol using WCF Data Service (FKA : ADO.NET Data Services).

First Create Empty ASP.NET Web Application project.

image

Add WCF Data Service Template to the newly created ASP.NET Web Application.

image

Now we need to Create our Data model which we are going to expose via OData. Here we can use LINQ to SQL or EF ( Entity Framework).

Here I am going to sue Entity Framework.

image

We are going to generate our model from existing Database.

image

    Provide the DB connection string Information.

image

Select the Tables you want to add to our Model.

image

image

Set Entity permission. Here I am setting all entity have Read access.

image

   Now hit F5 before that set start or up page as MyAlbum.svc.

image

Using REST API format we can access or query the Data . for example to get all customers Data we cause use the following REST URI

http://localhost:9570/MyAlbum.svc/Customers 

image

Nandri(Thanks)

Sreenivasaragavan.

No comments: