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:
Rename it to
ProductDAO.cs
. This will also rename the class name and all related places in the...