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
- In the Main function implement a DataServiceHost object and use as type ExampleDataService
- 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)
- 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
- In the Main function implement the proxy class AdventureWorksEntities,and add a function call to a Read method
- Implement the Read method by using a simple LINQ query that retrieves Product data from the AdventureworkEntities proxy and that display the results
- Run the application using as Startup projects the Host and the Client projects and you will get the following output
- When entering ‘Read’, the ADO.NET Data Service will be queried and a list of all products will be displayed