Tiered Architecture in C#.NET (DataAccess, Business, UI, Entity)
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.
DataAcces 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.