views:

233

answers:

2

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?

Thanks in advance

+2  A: 

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.

David Morton
A: 

Repository and ViewModel works perfectly together: ViewModel has Repository and View is bound to ViewModel.

Some examples may skip the ViewModel part, but using Repository directly in View in real application is bad idea in matter of separation of concerns.

Artur