Book Image

WCF Multi-layer Services Development with Entity Framework - Fourth Edition

By : Mike Liu
Book Image

WCF Multi-layer Services Development with Entity Framework - Fourth Edition

By: Mike Liu

Overview of this book

Table of Contents (20 chapters)
WCF Multi-layer Services Development with Entity Framework Fourth Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
2
Hosting the HelloWorld WCF Service
Index

Adding a data access layer


We have two layers, the service interface layer and the business logic layer, in our solution now. We don't have any code to interact with a data store to manipulate the underlying data. As said in the previous chapter, such code should be separated from these two layers, so now we will add one more layer, the data access layer, for this purpose. Within this third layer, we will query a real database to get the product information and update the database for a given product.

Creating the data access layer project

First, we will create the project for the data access layer. As we did for the business logic layer, what we need to do is add a C# class library project named LayerNorthwindDAL (where DAL stands for Data Access Layer) to the solution. Then, we need to change the default class file to be our Data Access Object (DAO) file.

Now, modify the Class1.cs file as follows:

  1. Rename it to ProductDAO.cs. This will also rename the class name and all related places in the...