asp.net - Passing ViewModel from Presentation to Service - Is it Okay? -


in 1 of views, have viewmodel populate 2 tables, , bind list<viewmodel> editable gridview (asp.net web forms).

now need send edited list<viewmodel> services layer update in database.

my question - okay send viewmodel services, or should stay in presentation? if not - should better use dto? many thanks.

nice question !

after several (hard) debates teammates + experience mvc applications, not recommend pass viewmodel service / domain layer.

  1. viewmodel belongs presentation, no matter what.
  2. because viewmodel can combination of different models (e.g : 1 viewmodel built 10 models), service layer should work domain entities.

otherwise, service layer end unusable because constrained viewmodels specifics 1 view.

nice tools https://github.com/automapper/automapper made make mapping job.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -