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

Posted In: ASP dot Net, C#, By , 5 Comments
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.
  • http://www.jpweightlossblog.com How I Shed T h i r t y P o u n d s in Only a Month

    Hi, good post. I have been thinking about this topic,so thanks for blogging. I will certainly be subscribing to your posts. Keep up the good posts

    • kutty

      I have a doubt on this framework. Can I send a string value to database and get the result back?
      If yes, give me solution please.

      thank
      kutty

  • http://www.google.com AndrewBoldman

    da best. Keep it going! Thank you

  • http://www.google.com GarykPatton

    Hello. I think the article is really interesting. I am even interested in reading more. How soon will you update your blog?

  • http://seesharpgears.blogspot.com seesharpgears

    Hello, I personally like this style of architecturing the applications. At this way you literally implement the N-Tier architecture. If you like to see my approach of designing the DAL and BAL (which is quite similar) you could read this post: Writing data access layer and business access layer. One thing that I want to point out, is that my DAL, which is architecturally equivallent with this one, uses object-relational mapping, meaning it directly maps the SQL table columns with the properties of the C# classes – does your approach offer that or similar functionality, or I have to use N-Hibernate or something ? Please read my post and tell me what do you think of my approach. Comments are appreciated.