Best practice for following the view model pattern

前端 未结 2 1474
孤独总比滥情好
孤独总比滥情好 2021-02-04 21:11

I\'m learning ASP.NET MVC for some times now. I follow some guidelines found on internet or in books and I would like to be sure I follow good practices in my developments regar

2条回答
  •  醉话见心
    2021-02-04 22:02

    You do use your domain model into your views. Your view model is just a container of domain models.

    Personally I have no problems with using entity or domain models in my views. I usually start with them. I switch to view models when the domain/entity model doesn't give me exactly what I want (instead of introducing logic into my views).

    No other code is dependent of your views, which makes it easy to refactor them and switch models at anytime.

提交回复
热议问题