從存儲過程中檢索數據我有以下兩個模型類在MVC
public partial class Items {
public Items() {
this.Items_RATINGS = new HashSet<Items_RATINGS>();
}
public int ITEMID { get; set; }
public string ITEMNAME { get; set; }
public virtual ICollection<Items_RATINGS> Items_RATINGS { get; set; }
}
public partial class Items_RATINGS
{
public int ItemsID { get; set; }
public byte ItemsRATING { get; set; }
public string COMMENTS { get; set; }
public virtual Items Items { get; set; }
}
我還創建存儲過程來檢討平均評分
CREATE PROCEDURE DBO.GET_ITEM_AVERAGERATING
@ITEMID INT
AS
BEGIN
SELECT AVG(OVERALLRATING) AS OVERALLRATING FROM ITEMS_RATINGS WHERE ITEMID = @ITEMID GROUP BY ITEMID
END
GO
在模型類,我已經加入
public virtual ICollection<GET_ITEM_AVERAGERATING_Result> GET_ITEM_AVERAGERATING { get; set; }
在控制器調用中,我試着加入
return View(db.Items.Include(c => c.GET_ITEM_AVERAGERATING).ToList());
但是,我沒有得到價值。它拋出一個錯誤。
請注意,標籤是獨立的。也就是說,你不能合併多個標籤來創建一個概念。標籤'[stored]'和'[procedure]'與單個'[stored-procedures]'標籤不同。請務必閱讀選擇標籤時出現的說明! – Charles