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?
- SharePoint 2010 ( ListData.Svc)
- Windows Azure
- 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.
Add WCF Data Service Template to the newly created ASP.NET Web Application.
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.
We are going to generate our model from existing Database.
Provide the DB connection string Information.
Select the Tables you want to add to our Model.
Set Entity permission. Here I am setting all entity have Read access.
Now hit F5 before that set start or up page as MyAlbum.svc.
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