【发布时间】:2013-08-24 03:55:14
【问题描述】:
在这里将 MVC4 与 EF 和 CF 一起使用(非常糟糕)
我有这样的课:
public class Feature
{
public int ID { get; set; }
public string Desc { get; set; }
}
还有这样的:
public class Device //change to Devices
{
public int ID { get; set; }
public string Name { get; set; }
public virtual ICollection<Feature> Features { get; set; }
}
在 Device 模型的 Edit 视图中,我希望有一个 ListBox,其中包含 Feature 模型的所有元素(显示的 Desc 属性),并且这些特征包含在 device.Features 集合中预先选择。
然后,当用户在 Edit 视图上单击 Save 时,ListBox 中所选项目的当前集合被写回到设备的 Features 集合中。
这个技巧的控制器代码和 cshtml 是什么样的?
感谢您的宝贵时间, 戴夫
【问题讨论】:
标签: asp.net-mvc-4 ef-code-first