Asp.net mvc 4 How to manage SQL Queries in a Web application?

Asp.net mvc 4 How to manage SQL Queries in a Web application?,asp.net-mvc-4,maintenance,Asp.net Mvc 4,Maintenance,Its a very basic question. I am new to ASP.NET MVC application. I am working on a very complicated 20+ Models and 150+ Views in the Application. I want to manage all the SQL queries that i will use in the application. Previously we use XML file to store query name and query. I wish we have some better option to store sql queries and parameters in the applicaiton. Suggestions appreciated.

Its a very basic question. I am new to ASP.NET MVC application.

I am working on a very complicated 20+ Models and 150+ Views in the Application.
I want to manage all the SQL queries that i will use in the application.
Previously we use XML file to store query name and query.
I wish we have some better option to store sql queries and parameters in the applicaiton. Suggestions appreciated.


#1

This is what I do.

I create repositories which takes care of running all the queries and accessing the data from database. And from controller if u want to pass any data or access any data to or from the view than you call that repository.

This makes you controller light weight (easy to test), the concerns are separated, and you can reuse your sql statements.

For more info check this.

Hope it helps you on building your application!


#2

Are you using an ORM like Nhibernate or Entity Framework or are you executing SQL queries directly from the application?

#3

Nope, I am using ADO.NET..I am exceuting through service for stored procedures. Few select queries i do execute from model.