ASP.Net 3.5 SP1 includes a new concept ADO.Net Data service. Commonly you can ask why we need one more service concept if we have WCF, ASMX services already?. Simply I could write a ASMX or WCF service to  provide API interface for my data. Yes its possible, the problem here is we have to write the code for everything(sorting, filtering, joins, CRUD operations etc) from scratch. Also for supporting different formats(JSON, ATOM, XML etc). Additional code required if we wish to expose it as a RESTful service. ADO.Net data services designed specially for these purpose. In a one go, we can a have service that performs CRUD operations, sorting, filtering etc and provides a RESTful interface supporting ATOM feeds and JSON formats without writing too much code and which well works with Entity Framework.

In three steps, you can expose your DB as web service.

  • Create a Entity Model from DB
  • Create a ADO.Net Data Service using Entity model
  • Add some initialisation code

Interestingly,  ADO.Net Data service is built on top of WCF and all the WCF features are available in it.It well supports LinQ. By default ADO.Net data services are RESTful in nature and supports ATOM feeds(default), JSON.

It has advantages and disadvantages as well. The advantages are REST service like URLs when accessing and manipulating data.

For example, An entity model db is with entities Customer, Products (say DB tables , here we treat them as entities). If the data service exposed as SampleDataService.svc then the below are some of the REST urls to access entities

http://<someserver>/SampleDataService.svc/Products (returns all the products as a atom feed by default unless specified)

http://<someserver>/SampleDataService.svc/Customers ( same returns all the customers)

Data service supports additional optional request parameters like $filter, $expand(use for joins) etc.

It supports interceptors and custom service operations which are then used to modify entity output.

Disadvantages are custom service operations with non relational data i,e. service operations to return only the entities defined in the entity model. It can’t return a custom entity that is not defined in the model.

Here I’m not explaining how to create them, there are several other articles already on MSDN and other blogs explaining in detail how to create and consume ADO.Net data services.

Follow these link for more detailed information http://msdn.microsoft.com/en-us/data/bb931106.aspx

I hosted some example services, Soon I’ll provide links.