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:

   

Published Tuesday, February 09, 2010 8:52 PM by StanleyGu

Comments

# re: Architect 3 : Building Data Access Layer Using Microsoft Enterprise Library 4.1

Wednesday, February 10, 2010 11:19 AM by kdavis6

Just one question, won't you need to reference your Data Entity Layer in your Data Access Layer?  How will it know what a Customer object is??  Thus, every time you update your Date Entity Layer you will need to recompile your Data Access Layer??  

# re: Architect 3 : Building Data Access Layer Using Microsoft Enterprise Library 4.1

Wednesday, February 10, 2010 7:52 PM by StanleyGu

Yes. You need to reference your Data Entity Layer and put using statement in your Data Access Layer. Then, you should be able to see the Customer class in your Data Access Layer.

# Wage web » Enterprise Library 4.1

Sunday, October 31, 2010 4:24 AM by Wage web » Enterprise Library 4.1

Pingback from  Wage web » Enterprise Library 4.1

# Wage web » wageweb

Friday, October 28, 2011 11:06 AM by Wage web » wageweb

Pingback from  Wage web » wageweb

Leave a Comment

(required) 
(required) 
(optional)
(required)