Firstly, the main difference is that the ViewModel may have behavior or methods that the DTO should not do !!!
Secondly, using DTO as a ViewModel in ASP.NET MVC makes your application closely related to DTO, and this is exactly the opposite goal of using DTO. If you do, what's the difference using your domain model or DTO, is it harder to get an anti-template?
Also ViewModel in ASP.NET can use DataAnnotations for validation.
The same DTO can have different ViewModel mappings, and One ViewModel can consist of different DTOs (always with object mappings, not composers). because I think itβs even worse if you have a ViewModel that contains a DTO, we will have the same problem.
At the presentation level, imagine that DTO is a contract, and you will get an object that you should consider unfamiliar to your application, and you will not have any control over it (even if you have a service, dto and your presentation levels).
Finally, if you make this clean separation, developers can easily work together. The person who develops ViewModels, Views, and Controllers does not have to worry about the DTO service or implementation layer, because he will make a comparison when other developers finish their implementation ... He can even use the Mocking tool or manual mockery to fill the presentation layer with data for testing.
riadh gomri Dec 27 '12 at 18:09 2012-12-27 18:09
source share