目前我有一个包含这些字段的产品数据库表:
名称 类别(例如产品类型) 子类别(例如包装) 价格
例如,A 类有 3 种包装。我希望它显示在三个不同的表格中。我可以分别取出三个表,但表显示相同的数据。
有人可以帮我吗?
我的公共 ViewResult Index() 控制器类中有这些代码。var productsCornIndustrial = from cornIndustrial in db.Products where cornIndustrial.Category == "Corn Oil" & cornIndustrial.SubCategory == "Industrial" 选择cornIndustrial;
return View(productsCornIndustrial.ToList());
var productsCornFoodservice = from cornFoodservice in db.Products
where cornFoodservice.Category == "Corn Oil" & cornFoodservice.SubCategory == "Foodservice"
select cornFoodservice;
return View(productsCornFoodservice.ToList());
var productsCornRetail = from cornRetail in db.Products
where cornRetail.Category == "Corn Oil" & cornRetail.SubCategory == "Retail"
select cornRetail;
return View(productsCornRetail.ToList());