I think I get the idea of ViewModel in MVC , but when performing updates and deletes, it seems like there should be a great model to send to the controller. I noticed that razor controllers use the ViewBag by default to select Selectlists.
I assume that makes the ViewModel (domain entities really) reusable in the return path, because it is devoid of unnecessary data. But it seems that using ViewBag does not make sense when using view models, since the view model may contain Selectlist , etc.
So my question is, what patterns exist to create separate βhosted dataβ models? (received this term from the book Esposito MVC 2). And how should relate to a data model based on view models? For example, it seems that I will try to include published data models in the view models. I am new to MVC and not from web-forms background. I would really like to understand the best samples for modeling the data that will be sent to the controller.
source share