4
Answers

How to make my MVC3 project a Mult Tier (DAL, BLL and UI) pr

r p

r p

11y
7.3k
1

Hi,

I am creating an application using MVC3. I follow the examples in -

http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/implementing-the-repository-and-unit-of-work-patterns-in-an-asp-net-mvc-application

Now, I like to make this project a Multi-Tier Application (Data Access Layer, Business Logic Layer and Application Layer).

In the above example I can see the author has a folder called DAL. So, I hope that the content I have to move to the DAL project. What all things should I move to my Business Logic Layer? I am thinking of creating the DLL of Data Access Layer and use it in the Business Logic Layer and the DLL of Business Logic Layer and use it in the Application Layer.

Could you please tell me what all things in the above example will go to each layer? 

Is there any better approach?

Thanks

Answers (4)
0
Iftikar Hussain

Iftikar Hussain

NA 18.9k 275.5k 11y
Hi,
  The difference between the UserTable.cs and UserInfo.cs, if you used Entity Framework, then UserTable.cs (Same table is exist in DB) will not able to modify. It will contain all the columns of the DB. So if you don't want all the columns and if you like some extra column then you can have UserInfo.cs
Ex. In the DB UserTable contain following fileds 
 - UserId
 - FirstName
 - LastName
 - Street
 - City
 - State
 - Country
 - Status
Now if you want in your application then you can have UserInfo.cs as 
- UserId
- Name
- Address
- Status
So it is upto you to have one more DataModel of your type in MVC

Regards,
Iftikar

0
Jignesh Trivedi

Jignesh Trivedi

NA 61k 14.2m 11y

hi,

Are you work with multi tier application previously?
here also it work similarly. MVC work as presention tire and you may add other n -tire ..

Please refer
http://www.codeproject.com/Articles/70061/Architecture-Guide-ASP-NET-MVC-Framework-N-tier-En
http://www.cmjackson.net/2010/01/18/mvc-and-n-layer-architecture/

hope this will help you.

0
r p

r p

NA 341 0 11y
I assume there is a table in the database called UserInfo and UserInfo.cs is the model of that table.
What is the role of UserTable.cs?
UserInforBusinessLayer.cs - hope this should be calling the functions in UserInfoDataAccess.cs?UserInfoDataAccess.cs should be using UserInfo.cs?

0
Iftikar Hussain

Iftikar Hussain

NA 18.9k 275.5k 11y
Hi,
  You can have project as shown below
DataModel - Put all your model class in this project (only for the BusinessLayer)

DataAccess - Put all your data access layer classes over here. In this layer you will just get data from your DB thru either EF or ADO.NET or classing way and use only the data model which is just the replica of your DB table.

BusinessLayer - Here you can put all your business layer classes, in this you will call DataAccess classes and format your BusinessLayer by using Business Data Model

For Ex.
I want to reterive user information from DB
EmpDataModel
        - UserInfo.cs
EmpDataAccess
        - UserInfoDataAccess.cs
        - UserTable.cs
EmpBusinessLayer
        - UserInforBusinessLayer.cs (will be using UserInfo.cs)
MainWebProject
        - Cotroller - will call EmpBusinessLayer
        - Views
        - And other folder like Images, Script etc. (but will not contain Model)

Regards,
Iftikar