c# - More than 2 Models in a ModelView with a twist -
i have been looking @ c# mvc while , getting in it. have come across how pass 2 or more domain models in view need ask security. have read on posting , can stopped binding inclusions , exclusions how effect viewmodel 2 or more model inside it. there still possibility of hidden fields in html resolve domain models , editable.
i have been looking make viewmodels give things want user edit seems on complicated, there better , easier way of doing this.
public ticketviewmodel { private ticket _ticket; public ticketviewmodel(ticket ticket) { _ticket = ticket; } public string title { { return _ticket.title; } } public list<comment> comments { { return _ticket.comments; } } }
as can see create new viewmodel ticket domain model main concern have returning list of domain model comments want them read only.
any appreciated.
consider readonlycollection, , method asreadonly provided list.
your comment property can rewritten -
public list<comment> comments { { return _ticket.comments.asreadonly(); } }
Comments
Post a Comment