0
目前,我有這些領域產品數據庫表:如何在一個數據庫的視圖中顯示多個表?
名稱 類別(如產品類型) 子目錄(如包裝) 價格
E.g A類有3種包裝。我希望它在三個不同的表格中顯示。我可以單獨得到三張表,但表格顯示的是相同的數據。
有人可以幫我嗎?
我在我的公共ViewResult指數()控制器類中有此代碼。 var productsCornIndustrial = from cornIndustrial in db.Products where corn cornIndustrial.Category ==「Corn Oil」& cornIndustrial.SubCategory ==「Industrial」 select 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());
那麼我在哪裏把我的數據庫代碼? – sling
那麼,我正在爲同一個解決方案中的Web應用程序創建3個項目。 1)核心 - 類庫,我有DAL代碼和存儲庫2)用戶界面 - MVC應用程序3)單元測試。因此,您可以將所有代碼添加到單獨的組件中,並將其組織在其中,然後在控制器中添加組件 –