1.2.4.ViewModel
Why need ViewModel?
It's a model specifically built for a view
To establish multiple model's relation, we can use ViewModel to do that
1.Create a folder which is called ViewModel
2.Create a ViewModel class which contains models
using System; using System.Collections.Generic; using System.Linq; using System.Web; using Vidly2.Models; namespace Vidly2.ViewModels { public class RandomMovieViewModel { public Movie Movie { get; set; } public List<Customer> Customers { get; set; } } }3.Modify controller
4.Modify View
Last updated
Was this helpful?