Showing posts with label ADO.NET Data Services. Show all posts
Showing posts with label ADO.NET Data Services. Show all posts

Friday, October 3, 2008

Tutorial: Creating a simple ADO.NET Data Service application.

ADO.NET Data Services enable applications to expose data as a data service that can be consumed by web clients within corporate networks and across the internet. A data service is reachable via regular HTTP requests, using standard HTTP verbs such as GET, POST, PUT and DELETE to perform CRUD operations against the service. The payload format used by the service is controllable by the application, but all options are simple, open formats such as JSON and Atom/APP.

This article will help you get quick Hands on experience on ADO.NET entity framework using VS 2008 and LINQ to SQL classes.

  1. Create a new ASP.NET web site / ASP.NET web application and name it AdventureWorksServices. (I am going to use the AdventureWorks sample database provided by MS for creating the ADO.NET Data service.
  2. Add a new LINQ to SQL class and name it AdventureWorksORM.dbml to the project. Drag and drop the respective tables from the AdventureWorks database for the entities.

  3. Add a new ADO.NET Data Service class and name it AdventureWorkService.svc. Change the class definition for the AdventureWorkService class to add the AdventureWorksORMDataContext class as given below

    public class AdventureWorksService : WebDataService<AdventureWorksORMDataContext>

    {

    public static void InitializeService(IWebDataServiceConfiguration config)

    {

    config.SetResourceContainerAccessRule("*", ResourceContainerRights.AllRead);

  4. Run the web site/ web application and you can start querying the database from the URI as given below.

  5. For getting the row 1 value for Product.