I am Learning ASP.NET MVC and downloaded a couple of sample apps. MusicStore etc...
I am coming from a wpf background where we had the MVVM Pattern. I have noticed that they used the concept of model and ViewModel.
In MVVM is pretty clear that you bind the view to the ViewModel injecting the model into the viewModel. In MVC you have a controller but I am not sure and confused how the all ties together,as I cannot see the model injected into the ViewModel
I have the following structure
- MyCompany.Entities.dll (All the models go here) EG Product
- MyCompany.Dal.dll (All the repositories go here)
- MyCompany.Services.dll (called by MyCompany.WebUI.Controller calls MyCompany.Dal)
- MyCompany.WebUI.MyApp
- MyCompany.Tests
From some of the examples I have seen your Model acts as a ViewModel.Am I correct?
Let's take a controller i have something like
public class ProductController
{
public ProductController(IProductRepository productRepository)
{
//omitted as not relevant
}
}
public class ProductVM
{
public ProductVM()
{
// Shouldn't we inject the model here RG Product
}
}
Is there some N-tier examples out there I can refer to? Is the concept of ViewModel a valid one in MVC? What is the standard?
Thanks for any suggestions.