【发布时间】:2021-10-07 13:14:30
【问题描述】:
我有基础模型
public class Group
{
public int Id { get; set; }
public int GroupVag { get; set; }
public ICollection<Vagon> Vagons { get; set; }
}
public class Vagon
{
public int Id { get; set; }
public string Nom_Vag { get; set; }
//[Required]
public int NumberGroup { get; set; }
[ForeignKey("Group")]
public int? GroupId { get; set; }
public Group Group { get; set; }
public virtual ICollection<SPR4664> SPR4664s { get; set; }
}
我的视图模型
public class ViewModelAddVag
{
public int Id { get; set; }
[Display(Name = "Name vag")]
[Required]
[MaxLength(8, ErrorMessage = "incorrect")]
public string Nom_Vag { get; set; }
[Display(Name = "Group vag")]
//[Required]
public int NumberGroup { get; set; }
[Display(Name = "TrainingType")]
[UIHint("DropDownList")]
public IEnumerable<SelectListItem> GroupDictionary { get; set; }
}
我想加入 View DropDownList table Group。 我为它做了 ViewModel。但我不知道该怎么做? 我想我应该在 ViewModel 使用属性 Get 中得到它
public IEnumerable<SelectListItem> GroupDictionary { get; set; }
【问题讨论】:
标签: c# model-view-controller asp.net-mvc-5