difference between models and view models

后端 未结 4 636
陌清茗
陌清茗 2020-12-29 13:05

I have been researching asp.net MVC project structure\'s for a new project and have a question about something is confusing me. What is the difference between models and vie

4条回答
  •  一个人的身影
    2020-12-29 13:27

    A model is simply a representation of an object in your application. However, there are a few different types of models that you should be aware of.

    1. Domain Model: This represents a domain object in your application, like a SQL table if you are using an ORM (Linq2SQL, EF).

    2. View Model: This represents an object that you want your end users to view/edit/etc. A view model could contain properties from several or no domain models and typically exclude properties that your end users should not be mucking with. View Models should only contain the elements that are needed to display the appropriate data to the end user for a specific request.

    Here is some Jimmy Bogard for you about View Models and their use.

提交回复
热议问题