Getting Started with ADO.NET Data Services

At the Sarasota Visual Studio 2008 InstallFest I showed off a number of ASP.NET 3.5 Extensions CTP Features. One was ASP.NET Dynamic Data, which I have talked about in several posts:


Another was ADO.NET Data Services.

For those of you who haven’t played with ADO.NET Data Services, you owe yourself a quick 5 minute look to think about the possibilities. Here is the quick introduction I provided at the Visual Studio 2008 InstallFest.


Install the ASP.NET 3.5 Extensions CTP

First things first, swing over to the ASP.NET Website to download and install the ASP.NET 3.5 Extesions CTP, which includes ADO.NET Data Services.

You can find it here:

Note this is a CTP, so common sense applies to what machines you install it on.


Create a New ASP.NET Website 

Run Visual Studio 2008 and Create a New ASP.NET Website

 Create ASP.NET Website


Add LINQ To SQL Classes and ADO.NET Data Services Items

We need some data, and one of the easiest ways to get data is to add a LINQ TO SQL Classes File to the solution and drag and drop Northwind Tables on it. We also need to add the ADO.NET Data Services Item to the solution as that is what we are trying to test. I called my items, Northwind and NorthwindDataService, respectively.

Hopefully LINQ To SQL is fairly easy to add. ADO.NET Data Services is even easier to add:

Add ADO.NET Data Services 


When all is said and done, the solution looks like this:

ADO.NET Data Services Solution


Configure NorthwindDataService to use NorthwindDataContext

Open up the NorthwindDataService.cs in the App_Code Folder and change the code to look like below:


public class NorthwindDataService :
<NorthwindDataContext> {

public static void InitializeService(IWebDataServiceConfiguration config)
*, ResourceContainerRights.AllRead);



Note that I added the NorthwindDataContext and set the access rules to allow access to all the data provided by the NorthwindDataContext in a read-only fashion.


Run the Website and Begin Querying

Now you can just run the website and start querying products or anything else in the Northwind Database using REST type URL’s.

Fetch ProductID = 1 : http://localhost:1453/WebSite5/NorthwindDataService.svc/Products(1)

Northwind ADO.NET Data Service


Fetch the Supplier for the Product : http://localhost:1453/WebSite5/NorthwindDataService.svc/Products(1)/Supplier

ADO.NET Data Services - Supplier 


Fetch Products 11 – 20 : http://localhost:1453/WebSite5/NorthwindDataService.svc/Products?$skip=10&$top=10


Fetch Name of Product : http://localhost:1453/WebSite5/NorthwindDataService.svc/Products(1)/ProductName/$value

I think I change Chai to Chai2 playing with the database, so your version will probably say Chai :)



Read the Documentation

Check out the documentation on ADO.NET Data Services for the ASP.NET 3.5 Extensions CTP at:


Pretty cool stuff…

This entry was posted in Uncategorized. Bookmark the permalink. Follow any comments here with the RSS feed for this post.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>