model-view-controllerrepository-patternviewmodel

Difference between the Repository Pattern and the View Model Pattern


I am trying to create a site using the ASP MVC Framework. Some of the documentation use the IRepository pattern to abstract the information being sent to the view for rendering, while others recommend using a ViewModel (as in MVVC).

What is the difference?

Aren't these the same concept?


Solution

  • The Repository pattern has more to do with how data is persisted and retrieved from the database, while the ViewModel pattern is a UI pattern that defines how to bind data to the UI. One is at the database level, while one is at the UI level, so they're completely different in that way.

    Read this for Repository Pattern, and read this for MVVM.