Social Icons

Thursday, 28 February 2013

Creation of Three Tier Architecture in .Net


How to Create Three Tier Architecture in C# .Net Windows Application 


Introduction:

In the Previous article i explained How to Write and Access ConnectionStrings from App.Config settings file, An overview of WPF Architecture.Now i will explain how to create three tier architecture for .Net Application.

Watch Video Explaining How to create a solution in 3 tier achitecture

Description:

3 Tier/Layered Architecture involves three layers. Commonly used names for layers are as follows

--> Presentation Layer
--> Busienss Access Layer (Business Logic Layer)
--> Data Access Layer.


Presentation layer:

     This is the presentation or User Interface layer to which user will interact. If it is Windows Application then the we have to take the project type either Windows Application, WPF Application Or Console Application.

Business Logic Layer:


   In this layer we will perform some validations on data before sending it to Data Access Layer. This layer is created by taking Project type as Class Library.

Data Access Layer:
   In this layer we will maintain some objects regarding communication with database. Example SqlConnection ,SqlCommand,Adapters, Readers etc Based on Data Base(Sql Server,Oracle, My Sql etc).

Here is Screen Shots of How to create Three Tier Architecture in C#.Net using Visual Studio.

  Click on New Project when visual studio loads . You will get see the following window
First create an empty solution by going other project types in Installed Templates section.
In this select the Visual Studio Solutions, then you will get blank solution then give name for the solution.

then press ok.
Now empty solution is created. You will see the solution explorer in following manner.


Now Our next task is to create Three Layers as we discussed.

First Layer is presentation layer. Here we can choose our project type either Windows or WPF Application type or Console Application etc.

Now Right Click on the Solution in the Solution Explorer. and Select Add option. You will get Add New Project Dialog Box From which we have to select the project type . Take Windows Application as follows


Give name for Project then Press Ok.
Now Presentation Layer is created. You will see the solution explorer like this


Now we have to create Business Access Layer.
Right click on the solution --> select new  -->New Project see the new project dialog box


Now Business Access Layer done. In the same manner create data access layer.

Right click on solution --> Add --> Select New Project --> dialog Box




give name as data access layer then press ok.

Now you completed creation three tier Architecture for windows application. In the same manner only you have to create three tier architecture for web also by taking project type as New Website.
finally you will see the solution explorer like this.




Conclusion:

  Three tier architecture involves three layers Presentation,Business Access,Data Access Layers. we can use any types of names here. Different people different names for these layer. What ever might be the name but this approach same. Hope you will get an idea how to create three tier/layered architecture in C#. In the next article i will explain how to consume three layers. I would like to have feedback from my blog readers. Your valuable feedback,Suggestions,Questions, Comments about this article are always welcome.

Related Tutorials


2 comments:

  1. Very useful article for the newbies like me. Kindly write the next article on the content to put in these layers.

    ReplyDelete
  2. Thanks krishna. Sure i will post how to consume three tier architecture in windows application and web application. Keep visiting.

    ReplyDelete

Please Give your Valuable Suggestions,Questions and Comments to improve my blog.