...
Info | ||
---|---|---|
If there is a single model on a view model, the name of the model in the ViewModelToModel can be ommitted as shown in the code below:
|
The ViewModelToModelAttribute in the code example above automatically maps the view model FirstName and LastName properties to the Person.FirstName and Person.LastName properties. This way, you don’t have to manually map the values from and to the model. Another nice effect is that the view model automatically validates all objects defined using the ModelAttribute, and all field and business errors mapped are automatically mapped to the view model.
...