This project is read-only.

adding list data directly into viewmodels

May 11, 2010 at 11:07 PM
Edited May 11, 2010 at 11:14 PM


I noticed that the lists are added late to the viewmodels..see below.

using System.Collections.Generic;
using MvcMusicStore.Models;

namespace MvcMusicStore.ViewModels
public class StoreManagerViewModel

public Album Album { get; set; }

public List<Artist> Artists { get; set; }

public List<Genre> Genres { get; set; }



Why cant the LINQ query for looking up Artist and Genre data be added directly to the viewmodel class since we all know that it comes from lookup tables in the LINQ Model and will not change?.

This way we only get to do it once in the model and not have to write code for this everytime we instantiate this viewmodel in the view.

Any examples on this please?