Consider the following code snippet
public class FirstViewModel
{
public IEnumerable<SelectListItem> GetSomeData()
{
//query dbcontext here
}
}
public class SecondViewModel
{
public Employee Employee { get; set; }
public Stock Stock { get; set; }
//more properties
}
So with the first snippet I can do the following in my code:
@Html.DropDownListFor(model => Model.Employee, new App.Models.ViewModels.FirstViewModel().GetSomeData(), "Please choose something")
In the second snippet I can do:
@Html.DropDownListFor(model => Model.Employee, new SelectList(Model.Employee), "Select Status")
What I'm trying to achieve is to have multiple models in one view for my MVC app. My question is would it be better to have a separate view model for each or one big view model which reference all other models. I'm very new to MVC so any help would be appreciated.