I am completely new to MVC architecture and having some doubts regarding the architecture and they are mainly due to not using entity framework, instead i've been using Data access with datatables and datasets to fetch data to the application. I would like to know the best practices regarding MVC pattern in case if someone can help out with certain links or pdfs(without entity framework). One more thing i would like to know and that is, from where do we call the DAL methods that obtain data from the database? from the Model classes or from the Controller Actions?
This is a brief demo of how one would implement data access code using MVC. Note that data access typically occurs in the controller action, not the model as someone indicated above:
[HttpPost]
public ActionResult Update(MyModel model){
//You call your data access code here and retrieve your entity
DataAccessObject dao = new DataAcessObject();
var entity = dao.Get(model.Id);
//Now that you have your entity, update its properties from the model that
//has been posted to this action
entity.Name = model.Name;
entity.Phone = model.Phone;
//Once your entity has been updated, pass it to the Update method of the DAO
dao.Update(entity);
}
There are plenty of ways to skin this cat, but something like the above should give you the idea. And unless your application is trivially small, you should look at implementing the Repository pattern to decouple your UI and data layers.