3 Tier Architecture in .NET - Sample Application
3 Tier Architecture in .NET - Sample Application
In this article we are going to look on how to create a 3 tier architecture application in .NET.
Basically three tier architecture needs to 3 projects to be created.
1. UI Layer
a. All you UI related stuffs like pages, user controls, CSS and java scripts will go into this.
2. Business Layer
a. All business rules are performed here.
3. Data Access Layer
a.All data access code like connecting to database and getting the details are done here.
4. Apart from these three projects, we will be having one more project called as Model. This will have all model classes which we use it in out application
It's not a good idea if you pass a dataset or data table from the DAL to the UI. We need to map those table fields to our custom class and we need to pass the custom object from the data access layer to UI. This is what we called ORM (Object Relational Mapping).
These things will come into picture like whenever, you want to expose your BAL through the Web Services, you can quite easily do that. And putting the model classes will make your code maintenance much easier. This will give the programmer to expand the current functionality of the classes when they are needed.
That's where the model classes come to the picture. I have 2 model classes used for this demo.
1. Employee.cs
a. This is a base class. Whenever we need to pass and get the employee details, we will be using this class.
2. EmployeeCollection.cs
a. This class is inherited from Collection
When you want to get the detail of one employee, then you can make use of Employee class. When you need to get the collection of the empoyees, you can use the EmployeeCollection. I have inherited from Collection
This application is developed using VS2005 and ASP.NET 2.0. Make sure you have Web Project Template installed in your machine else, you won't be able to open this application.
I have attached the demo application of 3 tiers. You can just download it and how a look how exactly we can implement the 3 tier architecture in the projects.
This is basic for n-tier architecture need to think more when you design your project on how to implement the tiered architecture.
Please feel free to post your queries. I will always be happy to answer and respond to your query.
By,
Brainstorming Guy aka Venkatarajan A
See details step wise tutorials of 3-tier architecture
http://dotnetfunda.com/articles/article71.aspx