I work with ASP.NET MVC 2 and one of the examples that I follow is the official ASP.NET MVC Music Store on codeplex.
In the project example, they have this scenario: There are three models: Albums , Artists , Genres .
What makes me doubt it is how they relate to their views, for example, when they want to edit an album, for which he needs a list of all artists and genres from the database, so they create a ViewModel called StoreManagerViewModel
public class StoreManagerViewModel{ public Album Album{get;set;} public List<Artists> Artists{get;set;} public List<Genre> Genres{get;set;} }
This ViewModel is passed to the view and allows intellisense to see multiple models in the view.
This method seems that I will have an extra class for almost all relationships in my model: If I have a Discography class and I want to associate artists with Discography, I would have to make another ViewModel, as shown above.
However, I do not like to have two properties inside the Album method:
public List<Artists> Artists{get;set;} public List<Genre> Genres{get;set;}
Is there a better way to do this other than ViewModels? Is there a cleaner way?
source share