David Hayden [MVP C#]

Sponsors

The Lounge

News

  • CodeBetter.Com Home

Other Links

Teas

Patterns & Practices

Florida .NET Developer

Book Reviews

Tampa ASP.NET MVC Developer Group

Advertisement

Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
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: http://www.asp.net/downloads/3.5-extensions/

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 :
            WebDataService<NorthwindDataContext> {
            
    public static void InitializeService(IWebDataServiceConfiguration config)
    {
        config.SetResourceContainerAccessRule
            ("*", 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:

http://quickstarts.asp.net/3-5-extensions/adonetdataservice/default.aspx

 

Pretty cool stuff...


Posted Tue, Jan 8 2008 1:34 PM by David Hayden

[Advertisement]

Comments

Christopher Steen wrote Link Listing - January 8, 2008
on Wed, Jan 9 2008 12:26 AM

ASP.NET Web Development Toolbox [Via: Chris Brandsma ] WPF WPF/Xaml Web News - 2008/01/08 [Via: rrelyea...

Noticias externas wrote DP 关注之一(2008/01/09)
on Wed, Jan 9 2008 3:56 AM

LINQKit www.albahari.com/.../linqkit.html LINQ Dynamic Query Library http://weblogs.asp.net

» Daily Bits - January 9, 2008 Alvin Ashcraft’s Daily Geek Bits: Daily links plus random ramblings about development, gadgets and raising rugrats. wrote &raquo; Daily Bits - January 9, 2008 Alvin Ashcraft&#8217;s Daily Geek Bits: Daily links plus random ramblings about development, gadgets and raising rugrats.
on Wed, Jan 9 2008 9:34 AM

Pingback from  &raquo; Daily Bits - January 9, 2008 Alvin Ashcraft&#8217;s Daily Geek Bits: Daily links plus random ramblings about development, gadgets and raising rugrats.

David Hayden - Florida .NET Developer - C# and SQL Server wrote ADO.NET Data Services Client Library for Microsoft Silverlight 1.1
on Sat, Jan 12 2008 9:56 AM
TerryLee wrote 推荐系列:2008年第03期 总5期
on Mon, Jan 14 2008 7:40 AM

概述又开始新一期的推荐系列,总共有10篇。1.ASP.NETPerformanceTips2.CachingImagesinASP.NET3.4ASP.NETAJAXJavaS...

Jacky_Xu wrote 推荐系列:2008年第03期 总5期
on Mon, Jan 14 2008 11:49 PM

概述

又开始新一期的推荐系列,总共有10篇。

1.ASP.NETPerformanceTips

2.CachingImagesinASP.NET

3.4ASP.NETAJAXJ...

Man vs Code wrote Project Astoria Links for 1/15/08
on Tue, Jan 15 2008 7:55 PM

Michael Sync has written a sample using the new Astoria Silverlight client library. David Hayden posted

Noticias externas wrote Project Astoria Links for 1/15/08
on Tue, Jan 15 2008 8:29 PM

Michael Sync has written a sample using the new Astoria Silverlight client library. David Hayden posted

MSDN Blog Postings » Project Astoria Links for 1/15/08 wrote MSDN Blog Postings &raquo; Project Astoria Links for 1/15/08
on Tue, Jan 15 2008 9:36 PM

Pingback from  MSDN Blog Postings  &raquo; Project Astoria Links for 1/15/08

Guru Stop wrote Link List: Language Topics, Data Service, jQuery,F#, Spec#, Specs Reading, etc...
on Mon, Feb 4 2008 7:09 AM

It started an email Mohamed Hossam (AKA, Bashmohandes) sent to my company's local office here in Egypt

David Hayden - Florida .NET Developer - C# and SQL Server wrote SQLSaturday - SQL Server Data Access Tips and Techniques with David Hayden - Tampa Florida
on Sun, Feb 10 2008 12:07 PM
David Hayden - Florida .NET Developer - C# and SQL Server wrote SQLSaturday - SQL Server Data Access Tips and Techniques with David Hayden - Tampa Florida
on Sun, Feb 10 2008 12:09 PM
VSone - Tag 2 - WCF, SQL Server Compact Edition, System.AddIn, ADO.NET Entity Framework, ADO.NET Data Services ("Astoria") | Code-Inside Blog wrote VSone - Tag 2 - WCF, SQL Server Compact Edition, System.AddIn, ADO.NET Entity Framework, ADO.NET Data Services (&quot;Astoria&quot;) | Code-Inside Blog
on Sun, Feb 17 2008 12:51 PM

Pingback from  VSone - Tag 2 - WCF, SQL Server Compact Edition, System.AddIn, ADO.NET Entity Framework, ADO.NET Data Services (&quot;Astoria&quot;) | Code-Inside Blog

David Hayden [MVP C#] wrote LINQ To SQL and Stored Procedures : Visual Studio 2008 and Repository Factory
on Tue, Feb 19 2008 9:53 AM

I forgot to mention that while I was at SQLSaturday in Tampa, Florida I ran into some very passionate

http://development.codebetter.com/blogs/david.hayden/archive/2008/01/08/getting-started-with-ado-net-data-services.aspx wrote http://development.codebetter.com/blogs/david.hayden/archive/2008/01/08/getting-started-with-ado-net-data-services.aspx
on Fri, Mar 28 2008 5:54 AM
http://tableadapter.codebetter.com/blogs/david.hayden/archive/2008/01/08/getting-started-with-ado-net-data-services.aspx wrote http://tableadapter.codebetter.com/blogs/david.hayden/archive/2008/01/08/getting-started-with-ado-net-data-services.aspx
on Fri, Mar 28 2008 5:54 AM