I want a method where I can call, that would query the database for my given query string. Which can be refferenced from different controllers/actions. (note, complexity of actual query is quite big).
So a few questions:
- Where would the code go. A new controller? Helper?
- How would I reference it (call it)?
What object, if following my current style, would be the return type.
public Something WebCostCentres() { using (var db = Database.OpenConnectionString(Mynamespace.Properties.Settings.Default.dbConnString, "System.Data.SqlClient")) { //ViewBag.CostCentres = db.Query("SELECT DISTINCT CostCentreNo"); return db.Query("SELECT DISTINCT CostCentreNo"); } }
Databasehere - is that entlib?