As I understand it, domain models are classes that describe only data (aggregate roots). These are POCOs and do not reference external libraries (nothing special).
View models, on the other hand, are classes that contain domain model objects, as well as all interface-specific objects such as SelectList. ViewModel includes using System.Web.Mvc;.
The repository retrieves data from the database and passes it to us through the domain model objects. Which mechanic or device creates view model objects by populating them from a database? Will the factory have access to the database? Could you map specific types, such as System.Web.Mvc, to the repository? Something else?
For example, if you have a drop-down list of cities, you should reference the SelectList object in the root directory of the View Model object, next to the DomainModel link:
public class CustomerForm {
public CustomerAddress address {get;set;}
public SelectList cities {get;set;}
}
Cities must come from the database and be in the form of a pick list object. We hope that you will not create a special repository method to retrieve only individual cities, and then create a backup second SelectList object to have the required data types.
source
share