I'm learning some stuffs about Model View Controller architecture, because I want to implement it in my project, so as much as I understand it goes like this:
M - Model, part of project where I add connection to database (LINQ TO SQL Classes or ADO.NET Entity for example)
V - View, part of project where I keep my forms if we are talking about c# windows form application
C - Controller, part of project where I'm writing methods for retrieving and inserting data from my forms to database, for example: if I want to select all customers from database I would do next:
public class CustomerController
{
public static List<Customers> GetActiveCustomers()
{
return DataServices.DB.proc_SelectAllActiveCustomers().ToList();
}
}
So in code above, in my controller, I am calling stored procedure called proc_SelectAllActiveCustomers
, which will fill my form with All active customers if I call it from some of my forms..
So guys is this correct? Or I should call my stored procedures somehow from Model, or actually that's it because DataServices.cs
is located in Model and it's used for opening connection to database?
I'm confused about this..
Could anyone explain me is this right or not?
Thanks guys, cheers!
Ideally, your model should do absolutely nothing. The controller should pass it to the view to render it and that's it. If a stored procedure needs to be used, you would do it in the controller.