My "Manipulate Data in the Cloud with ADO.NET [Data Services Framework]" story for Visual Studio Magazine's May 2008 issue includes downloadable sample NwindDataService.sln and NwindDSClient.sln data service and client projects. The two solutions expand from their vs0805rj.zip file into an outer \AstoriaCTP folder, which contains the Readme.txt file and NwindDataService and NwindDSClient folders.
The original sample projects were based on the latest ADO.NET Data Services Framework CTP at the time the magazine was printed. The Astoria Team's ADO.NET Data Services Framework Beta 1 is Live! post has a list of most SP1 changes.
Entity Framework Beta 3 served as the data source. The ADO.NET's Entity Framework Breaking Changes - Visual Studio 2008 & .NET 3.5 SP1 Beta post of May 14, 2008 has the breaking changes only.
Supporting ADO.NET Data Services Framework SP1 Beta and Entity Framework SP1 Beta required quite a few changes to the source code and references. You'll be able to download the updated code shortly from the VSM site; in the meantime, you can download AstoriaBeta.zip from my SkyDrive account. The updated project expands into an outer \AstoriaBeta folder with an updated Readme.txt file and same-named subfolders.
Figure 1: The NwindDataService.Northwind Data Service's Default Output Displaying the Tables Available as Atom <Feed> Entities
Following are changes required to update NwindDataService to SP1 Beta from the previous version:
1. Change Microsoft.Data.Web namespace to System.Data.Services
2. Change WebDataService to DataService
3. Change ResourceActions to UpdateOperations
4. Change IWebDataServiceConfiguration to IDataServiceConfiguration
5. Change WebDataServiceException to DataServiceException
6. Change config.SetResourceContainerAccessRule("*", ResourceContainerRights.All); to config.SetEntitySetAccessRule("*", EntitySetRights.All);
7. Replace <%@ ServiceHost Language="C#" Factory="Microsoft.Data.Web.DataServiceHostFactory, Microsoft.Data.Web, Version=184.108.40.206, Culture=neutral, PublicKeyToken=b77a5c561934e089" Service="NwindDataServicesCS.Northwind" %> with
<%@ ServiceHost Language="C#" Factory="System.Data.Services.DataServiceHostFactory, System.Data.Services, Version=220.127.116.11, Culture=neutral, PublicKeyToken=b77a5c561934e089" Service="WebDataService.Northwind" %>
I recommend creating the Entity Data Model's .edmx and designer, as well as the *.svc file from scratch, and importing custom code after you get the service operating in its default mode. While upgrading I encountered a number of mysterious runtime errors that don't provide suggestions on how to solve the problems.
Figure 2: The Astoria client displaying the result of a LINQ to REST query against the Products and Categories tables.
These changes are required to update NwindDSClient to SP1 Beta from the previous version:
1. Change Microsoft.Data.WebClient namespace to System.Data.Services.Client
2. Change context.AttachObject("Customers", cust); to context.AttachTo("Customers", cust);
3. Change public string url = null; to public Uri url = null;
4. Change url = "http://localhost:" + txtPort.Text + "/Northwind.svc"; to
url = new Uri("http://localhost:" + txtPort.Text + "/Northwind.svc");
5. Change WebDataContext to DataServiceContext
6. Change WebDataQuery to DataServiceQuery
You'll need to rewrite Query Interceptors in a new format similar to that shown in Pablo Castro's Looking for feedback: query caching in data services post of March 31, 2008.
You'll also need to rebuild the *.cs class file for your object model with the new DataSvcUtil.exe command line tool that has a simpler set of arguments. The new CreateNorthwindCS.cmd file has the following content:
\Windows\Microsoft.Net\Framework\V3.5\DataSvcUtil.exe /out:"Northwind.cs" /uri:http://localhost:52660/Northwind.svc