您好,我是 mvc 3 的新手,我需要一些指针/帮助来填充下拉列表。我有 3 个类是我的域类。基本上我想做的是制作一个下拉列表,其中将填充特定成员租借的电影。最简单的方法是什么?是使用 ViewBag 还是制作 ViewModel?
public class Member
{
public virtual int MemberId { get; set; }
public virtual long PersonalNr { get; set; }
public virtual string Name { get; set; }
public virtual string LastName { get; set; }
public virtual List<Rental> Rentals { get; set; }
}
public class Movie
{
public virtual int MovieId { get; set; }
public virtual string Name { get; set; }
public virtual bool IsInStock { get; set; }
}
public class Rental
{
public virtual int RentalId { get; set; }
public virtual int MovieId { get; set; }
public virtual Movie Movie { get; set; }
public virtual int MemberId { get; set; }
public virtual Member Member { get; set; }
public DateTime startDate { get; set; }
public DateTime dueDate { get; set; }
}