Architect 3 : Building Data Access Layer Using Microsoft Enterprise Library 4.1
You have a Customer table with three fields: ID, LastName and FirstName. You are building a data access layer to retrieve all the records from the Customer table and return the result as a collection of Customer objects. You want implement it using Microsoft Enterprise Library.
1. In your Data Access Layer project, add references to the following Microsoft Enterprise Library DLLs:
Microsoft.Practices.EnterpriseLibrary.Data.dll
Microsoft.Practices.EnterpriseLibrary.Common.dll
Microsoft.Practices.ObjectBuilder2.dll
2. At App.config or Web.config, add the following dataConfiguration section:
3. At App.config or Web.config, add the following connectionString:
4. At the Data Entity Layer, create a entity class Customer:
5. At the Data Access Layer, create a class CustomerDAL and make sure put the following using statements:
6. Create a method GetCustomers in the CustomerDAL class with the following implementation: