Showing posts with label Data Service. Show all posts
Showing posts with label Data Service. Show all posts

Wednesday, August 5, 2009

[Tutorial] ADO.NET Data Services
Part 5 – Custom Data Sources 2/2

The last part described how to replace the Entity Framework with custom Data Sources. This part goes into more detail concerning the necessary modifications in the Host & Client projects.

At the end of this part you will have a fully working ADO.NET Data Service that is based on your own custom Data Structure and Data Sources.

  • Open the Client project and add a new Service Reference to the ExampleDataService2
ADO Data Services - Part 5 - 01ADO Data Services - Part 5 - 02

  • Change the implementation in the Main function and add a new proxy to the new ADO.NET Data Service

ADO Data Services - Part 5 - 03

  • Change the implementation in the Read function and add a two new function calls in dependency of the user input

ADO Data Services - Part 5 - 04

  • Add the implementation of the new ReadEF and ReadCustom functions so that the correct proxy is used to query for data and display it in the console

ADO Data Services - Part 5 - 05 ADO Data Services - Part 5 - 06

  • Open the Host project and modify the Main function so that both ADO.NET Data Services are hosted on different addresses

ADO Data Services - Part 5 - 07


Share/Save/Bookmark

Tuesday, August 4, 2009

[Tutorial] ADO.NET Data Services
Part 4 – Custom Data Sources 1/2

The last part showed how to host an ADO.NET Data Services and how to create a proxy to consume it. This part describes how to replace the Entity Framework part with custom Data Sources (for example POCO business objects).

By doing this, you will get the full functionality of ADO.NET Data Services but the flexibility to use you own custom Data Sources (Object in Memory, Oracle DB, Data Cubes, Files, etc…).

  • Open the ADO.NET Data Service project and add some new classes that will serve as structure for your custom Data  Source  (for example  Invoice, InvoiceLine, Thirdparty and BusinessEntities)

ADO Data Services - Part 4 - 01 ADO Data Services - Part 4 - 02  ADO Data Services - Part 4 - 03

  • The BusinessEntities class serves as container for the different custom entities that you want to expose, they are initialized in the constructor for the example and must be accessible via public IQueryable properties

ADO Data Services - Part 4 - 04

ADO Data Services - Part 4 - 05ADO Data Services - Part 4 - 06 ADO Data Services - Part 4 - 07ADO Data Services - Part 4 - 08

  • Add a new item of type ADO.NET Data Service

ADO Data Services - Part 4 - 09

  • Change the Data Service code of the new ExampleDataService2 and add as type the custom BusinessEntities

ADO Data Services - Part 4 - 10


Share/Save/Bookmark

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

Tuesday, June 30, 2009

[Tutorial] ADO.NET Data Services
Part 1 - Setting up the projects

This is the first part of a series that is dedicated to ADO.NET Data Services. It shows how to configure a web project, and two console projects for using ADO.NET Data Services and serves as fundament for all following parts.

  • Create a new ASP.NET Web Application

ADO Data Services - Part 1 - 01

  • Add a new item of type ADO.NET Data Service

ADO Data Services - Part 1 - 02

  • The ADO.NET Data Service is now generated using a standard template

ADO Data Services - Part 1 - 03

  • Add two standard console projects to the solution (for Client and Host)

Share/Save/Bookmark