Why Two Classes, View Model and Domain Model?

前端 未结 5 1248
予麋鹿
予麋鹿 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:26

    you need to remember that your domain model classes are only used internally; that is, they are never sent to the client. That’s what your service model types (View Model types) are used for—they represent the data that will be going back and forth between the client and your service.

提交回复
热议问题