security and logic
if you give all the data to a frontend that only want to see some then you risk revealing stuff that shouldn't be seen
and also what happens when you have to deal with all those fields when de/serializing, when saving, and so on? you wonder why did you get that field, you wonder what do you have to do if the field is changed (should i update, should i ignore?) and so on
so creating the model you need for that specific feature is usually the best road to go down
no i don't give all data on frontend i build a complete viewmodel for diff situation then i get data from database and use that view model on front end and use properties that i need for that page.
it doesn't matter at which level, repo->logic, logic->view, the practice is (almost) always using a dedicated model
so you say create multiple model for each situation is better?
99% yes also pay attention to eventual shared/base models
ok thanks. i will do this.
Обсуждают сегодня