Thursday, July 30, 2009

[Tutorial] ADO.NET Data Services
Part 3 – Host & Client Projects

The last part explained how to use the Entity Framework in combination with ADO.NET Data Services. This part shows how to host an ADO.NET Data Services and how to create a proxy to consume it.

  • Open the Host Console project that was created in the first part of the series and add a Reference to the ADO.NET Data Service project

 ADO Data Services - Part 3 - 01

  • In the Main function implement a DataServiceHost object and use as type ExampleDataService

ADO Data Services - Part 3 - 02

  • Add an application configuration file and configure the connection string to the AdventureWorks data source (you may copy the ConnectionStrings section from the WebConfig file of the ADO.NET Data Service project)

ADO Data Services - Part 3 - 03 ADO Data Services - Part 3 - 04

  • Open the Client Console project that was created in the first part of the series and add a Service Reference to the ADO.NET Data Service project (click on Discover), which will auto-generate some proxy classes

ADO Data Services - Part 3 - 03

  • In the Main function implement the proxy class AdventureWorksEntities,and add a function call to a Read method

ADO Data Services - Part 3 - 06

  • Implement the Read method by using a simple LINQ query that retrieves Product data from the AdventureworkEntities proxy and that display the results

ADO Data Services - Part 3 - 07

  • Run the application using as Startup projects the Host and the Client projects and you will get the following output

ADO Data Services - Part 3 - 08ADO Data Services - Part 3 - 09

  • When entering ‘Read’, the ADO.NET Data Service will be queried and a list of all products will be displayed

ADO Data Services - Part 3 - 10


Share/Save/Bookmark

Monday, July 20, 2009

[Tutorial] ADO.NET Data Services
Part 2 – Using the Entity Framework

This part of the series explains how to use the Entity Framework in combination with ADO.NET Data Services. This is the most easy and quickest way to provide access to a Data Source that can be addressed by the Entity Framework.

  • Add a new Item of type ADO.NET Entity Data Model

ADO Data Services - Part 2 - 01

  • Generate a new model from the AdventureWorks DB in your SQL Server (you might need to install it see my Entity Framework Tutorial if you need help on this)

ADO Data Services - Part 2 - 02

ADO Data Services - Part 2 - 03

  • Change the Data Service code and add as type the newly generated AdventureWorksEntities

ADO Data Services - Part 2 - 04


Share/Save/Bookmark