我正在尋找幫助。 我正在進行基於MVC的練習。 我的模型包含2個類。 DVD和類別如何基於對象包含在對象列表中的值創建對象列表C#
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和分類是模型文件夾下。 我想要做的是在我的控制器中的類別(在公共ActionResult詳細信息(INT ID = 0)的方法) 中創建一個列表來收集所有類別爲id 1的dvd。
我發現了一些simillar,但我有問題,當我必須檢查DVD的類別id是否與我正在尋找的相同。
Search list of object based on another list of object c#
誰能幫我做嗎? 謝謝
_「現在是一種方法的類別」_你是指_「class」_而不是? –
這是簡單的類/對象,還是這些表示使用EF的多對多數據庫關係或其他? –