ASP.NET MVC 2 validation using DTOs instead of domain entities
Posted
by Kevin Pang
on Stack Overflow
See other posts from Stack Overflow
or by Kevin Pang
Published on 2010-04-03T14:52:01Z
Indexed on
2010/04/03
15:03 UTC
Read the original article
Hit count: 589
asp.net-mvc
|validation
I'm struggling to mesh two best practices together:
- Using DataAnnotations + ModelBinding for validation in ASP.NET MVC 2
- Using DTOs instead of domain entities when passing data via the ViewModel
If I want to pass over DTOs instead of domain entities, then leveraging DataAnnotations + ModelBinding for validation would require me to specify validation attributes on my DTO classes. This results in a lot of duplicated work since multiple DTOs may hold overlapping fields with the same validation restrictions. This means that any time I change a validation rule in my domain, I have to go find all DTOs that correspond with that value and update their validation attributes.
© Stack Overflow or respective owner