Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where queries should be placed in ASP.NET MVC

I am using ASP.NET MVC, building an ERP with Framework 4.0 and SQL Server 2008.
My question is where should query be placed? I saw multiple methods while surfing. Few of them are as follows:

  • In Models
  • In Separate Files, that are in DAL Folder
  • In Separate DAL Project

I am still confused about using queries in Models after research.

Further Info:
I am using simple query method, not Linq and Entity Framework.
I have a plan to also convert this project to Desktop Application in future.

Another Question is that How business Logic works in ASP.NET MVC if I use it?

Detail About Project
It is a Website + Online Information System of a Company with around 40-50 pages of both.
User can enter in Info System by Signing in from website.

Before Voting to Close Leave a comment so that I can learn something.

like image 375
syed mohsin Avatar asked Sep 04 '13 15:09

syed mohsin


1 Answers

Your question is about infrastructure of a project that depends on lots of factors.

Considering the information you have provided in your question:

I have a plan to also convert this project in Desktop Application in future.

for the sake of usability, you should have your Data Access Layer in a separate project.

If you are interested in obtaining more information about the infrastructure of a project, I recommend to you: Microsoft Spain - Domain Oriented N-Layered .NET 4.0 Sample App that is well documented and gives you much information that you need to produce an enterprise level application.

like image 146
Abbas Amiri Avatar answered Oct 02 '22 16:10

Abbas Amiri