Hello all,
Been around here for a while but this is my first question @ so.
Scenario: Mvc site. Viewmodels for most pages. Each viewmodel contains models or iqueryables acquired from different repositories.
Each source is updated frequently (from outside the scoop of the site) so even if caching local it will be a lot of datasource hammering.
The problem we're facing is that when a viewmodel is created using more then one repository each of them trigger a connection/fetch to the datasource (if they need to repopulate).
This could easily be avoided by returning a complete viewmodel from the repository. Then the repository could use a single connection (in most cases even with only one sql stored procedure) to fetch all needed data.
Someone mentioned that viewmodels should not be involved in repositories. I don't actually see any problems with this so my question is what could be the impact?