我想在用户点击类别链接时显示每个类别的产品列表,然后链接将如下所示:
/Warehouse/Browse?category=Film
//Warehouse controller used to display the product list
WarehouseController
中的我的浏览操作将
public ActionResult Browse(string category)
{
var cat = db.Categories.Include("Products").Single(c => c.CategoryName == category);
return View(cat);
}
类别模型类:
public class Category
{
public int CategoryId { get; set; }
public string CategoryName { get; set; }
public virtual ICollection<Product> Products { get; set; }
}
产品型号类:
public class Product
{
public int ProductId { get; set; }
public string ProductName { get; set; }
public int CategoryId { get; set; }
public virtual Category Category { get; set; }
}
如何在浏览视图中使用分页?