Domain Model Vs View Model
In the mvvm pattern the viewmodel is used to isolate the model from the view.
Domain model vs view model. Difference between domain model viewmodel and editmodel in asp net mvc we often hear terms like model view model etc in context of mvc applications. To represent the model you could use simple dto classes which again is mapped to a database through e g. Tomorrow i ll show my blog in a mobile version and at that time i may create a simple view model that contains only fewer properties.
Or just create a viewmodel component object that contains all three items. It s not a domain model but a viewmodel because a specific view uses it. These are the view model and domain model.
So the solution is to have one model for the view to bind to and a different model which really is the model. The posts and comments are domain models while the blogviewmodel is the view model i created specially for the view. I created a view model called blogviewmodel that contains the latest posts latest comments and other stuff as properties and i bind my view with this model.
Although these are kind of basic concepts for people who are into asp net mvc for some time or mvc pattern in general but can be really confusing for new comers. A common scenario would be to add links. If you need to change or enhance the dto then create a viewmodel.
Does that mean i need to force a relationship between the three. In most of the times our ui page presentation requirements are different from domain requirements. But i ve never seen a viewmodel class which is modelled as a dto.
Viewmodel classes mostly have behavior which dtos don t have. The models in a particular domain space represent the real world objects. Domain model is about poco and not being bound by technical constraints of either data shown view or persisted in a db or otherwise.