Why Two Classes, View Model and Domain Model?

前端 未结 5 1237
予麋鹿
予麋鹿 2020-11-29 02:47

I know it could be bad to use domain models as view models. If my domain model has a property named IsAdmin and I have a Create controller action to create users, someone co

5条回答
  •  遥遥无期
    2020-11-29 03:25

    Sometimes you need to display the data in a specific manner (ie, displaying a date in the format mm/dd/yyyy vs. yyyy/mm/dd) and often it is easier to make this property in the view and not in the domain model, where you would (or should) have a mapping to a column in your db.

提交回复
热议问题