Tiered Architecture in C#.NET (DataAccess, Business, UI, Entity)

Posted In: ASP dot Net, C#, By , 5 Comments
advertisement

advertisement

Download the Code Here

This post includes a sample download and tutorial of how to build a neat and clean tiered architecture using C#.NET. A good introductory example of building an Elegant Data Access layer can be found at the following location in C-SharpCorner:

 

 

http://www.c-sharpcorner.com/UploadFile/rmcochran/elegant_dal05212006130957PM/elegant_dal.aspx

Many thanks to Matthew Cochran for posting such an excellent article on Data Access layer.

I have used his idea to build the DataAccess Layer with lots of modifications and additional functinalities.

Tiered Architecture

Tiered Architecture

DataAcces Layer

Data Access Layer

Data Access Layer

The architecture uses Template pattern and Generics. The SaveRegistration and readUserByUse… are the concrete classes which contain the name of query and the command type. An example code is given for download. With this pattern, only the concrete classes like SaveRegistration need to be created. The layer can be modified to adjust with Enterprise library as well. Please download the code sample to dig out further details.

NOTE: If the database fields have same name as the query parameters, the parameters will be handled automatically.

Business Layer

The Business Layer comprises of the business objects which acts as a communication interface between UI layer and Data Access Layer.

EntityLayer

It contains all the business entities which removes cyclic reference problem between dataAccess layer and Business layer.

Download the Code Here

About the Author:

Web designer/developer holding Masters degree in IT, currently living in Australia. Passionate about Wordpress, PHP, Fireworks and Jquery.