【发布时间】:2013-12-13 14:00:24
【问题描述】:
我正在寻求帮助。 我正在做一个基于 MVC 的练习。 我的模型包含 2 个类。 DVD 和类别
public class DVD
{
public int ID
{ get; set; }
public string Title
{ get; set; }
public decimal Price
{ get; set; }
public int Quantity
{ get; set; }
public int Duration
{ get; set; }
public string Image
{ get; set; }
public virtual IList<Category> Categories_List
{ get; set; }}
现在类别是一个方法包含以下内容
public class Category
{
public int Id
{ get; set; }
public string Title
{ get; set; }
public virtual IList<DVD> DVDs
{ get; set; } }
DVD 和 Category 都在 Model 文件夹下。 我想要做的是在我的类别控制器中创建一个列表(在 public ActionResult Details(int id = 0) 的方法内) 例如,收集 ID 为 1 的类别中的所有 dvd。
我发现了一些类似的东西,但是当我必须检查 DVD 的类别 ID 是否与我要查找的相同时遇到了问题。
Search list of object based on another list of object c#
有人可以帮我做吗? 谢谢
【问题讨论】:
-
"现在的 Category 是一个方法" 你的意思是 "class" 吗?
-
这是普通的类/对象,还是使用 EF 表示多对多数据库关系,还是什么?
标签: c# asp.net-mvc asp.net-mvc-4