Is it a bad practice using model classes in controller in mvc?

前端 未结 4 1832
春和景丽
春和景丽 2021-01-05 15:22

I wanted to compare with best practices when working with an ORM or database tables in asp.net mvc. One of the major questions I have is should I instantiate

4条回答
  •  孤街浪徒
    2021-01-05 16:16

    Actually, it depends, maybe all you need is exactly show your model in UI. then I see no sense in wrapping it. But most of the times, even if you think you do not need to change anything in a model before showing it into view, you may need to do it in future. So the better way is to separate your exact model and future view data. It gives you more flexibility if you ned to change something (like change DB structure but view will remain the same)

提交回复
热议问题