VOS.VirtEntityFrameworkINFDatService
Creating an ADO.NET Data Service
An ADO.NET Data Service for the Informix tables can be created using the Entity Data Model created in the Creating EDM in Visual Studio 2008 section.
- Open the stores_demo project created in the Creating EDM in Visual Studio 2008 section.
- Right click on the stores_demo project name in the Solution Explorer pane, then select the Add -> New Item menu options.
- The Add New Item dialog will appear.
Choose the ADO.NET Data Service template.
Give it the name WebDataService.svc, and click Add to create the ADO.NET Data Service.
- In the newly created WebDataService1.svc.cs Data Service file, add the data source class name of stores_demoEntities (note this is the name set in the Creating EDM in Visual Studio 2008 section) as the
DataService name. Enable access to the Data Service by adding the entry config.SetEntitySetAccessRule("*", EntitySetRights.All); in the InitializeService method.
// C# using System; using System.Web; using System.Collections.Generic; using System.ServiceModel.Web; using System.Linq; using System.Data.Services; namespace SimpleDataService { public class Northwind : DataService<stores_demoDemoEntities> { public static void InitializeService(IDataServiceConfiguration config) { config.SetEntitySetAccessRule("*", EntitySetRights.All); } } }
- To test the Data Service, simply hit Ctrl+F5 within Visual Studio.
This will start the development web server, run the Data Services server inside, and load a Web browser page displaying the list of tables/entities for the stores_demo database catalog.
- To access a specific entity instance like the CUSTOMERS table customer number 101 record, use this convention http://host/vdir/WebDataService1.svc/customer(101) .
NOTES
-
Important - To view Atom (the default format returned by an ADO.NET Data Service) in Internet Explorer, you must first ensure that Feed Reading View is turned off.
This can be done on the Content tab of Tools in Internet Options.
- If a Data Services entity instance URI page fails to load you can turn Verbose errors on by adding
config.UseVerboseErrors = true;
in thevirtuoso.svc.cs
InitializeService method. This enables you to obtain more detailed information from the server as to why the page failed to load:
public static void InitializeService(IDataServiceConfiguration config) { config.UseVerboseErrors = true; config.SetEntitySetAccessRule("*", EntitySetRights.All); }