To implement ADO.NET Data Service, you need Visual Studio 2008 SPI, a data¬base and a web browser client. We used the 'School' databaseJehat comes with SQL Server 2008. art by creating an ASP.NET Web Application project in and name it ADODS_Sample I. We have used C# for creating this. The first step is to create a
conceptual model known as the Entity Data Model (EDM) of the sample data¬base. This can be done by clicking on Project>Add New Item and then selecting ADO.NET Entity Data Model. After this, simply follow the wizard (check out our Nov 2008 issue for in depth explanation of this). This EDM will act as layer between the database and client from which the data would be picked up. After creation of'School.edmx' file, you have to create the data service that will expose data as service to be picked up by any client.

To create a data service, clickon Project>Add New Item and this time add 'ADO. NET Data Service' and name it 'School.svc'. We now have to make changes to the 'School.svc.cs' file.

Name:  ADO.NET Data Service.jpg
Views: 52
Size:  40.6 KB

To display output of the project, one has to make certain changes in browser settings. In Internet Explorer, go to 'Options', click on 'Advanced' tab, and under settings go to 'Browsing'. Uncheck Disable script debugging. Next click on the 'Content' tab and then click on 'Settings'. Uncheck 'Turn on feed reading view'. Press 'FS' to start debugging, browser will open with following URL:

Here you will find XML representation of the data that can be used by any client. Now to drill down further, one can find data related to 'Department' and 'OnlineCourse' tables using following URI's:

Similarly, other URIs can be provided to clients so that they can look for data as per their needs. Moving one step ahead, one can also display data associated with 'DepartmentID' (valued I) in other table named 'Course'. The URL for this is:

Using ADO. NET Data Service, we have shown here is how data repre¬sented as EDM is exposed as a web service. The same data can be exposed via RSS feeds as well. Plus, apart from converting URIs to Entity Framework Object Services method calls, you can even use XML documents, web service etc.