c# - Should I be using more than one viewmodel for a database table? -
bit of confusion, i'm sure can cleared :).
lets have table called "contacts". "index" view table datatable, listing contacts in table first name, email , phone. now, have viewmodel containing firstname, email , phone.
next need details page, have details each contact in full, ie, fullname, first or second contacts, other phone numbers, website address , notes etc. should second viewmodel?
then we'd have create page, had have fields filled in. viewmodel?
finally, go same class file or separate files?
thanks
as usual answer ain't common, depends on how want implement it. sake of patterns , organized code, recommend have:
- separate viewmodel per view: each viewmodel should contain many data many want display/work on given view.
- for sake of separation of concern , unit testability: 1 class - 1 file, , 1 class per task class concerned for. given class required change 1 reason only.
Comments
Post a Comment