0
不能在foreach循環訪問存儲過程的SQL SELECT語句的列值
此錯誤occure運行時代碼 enter image description here無法訪問存儲過程值foreach循環在asp.net mvc的
這是存儲過程
ALTER proc [dbo].[getAuthorBooks]
@id int
as
Begin
select BookName,Paid from Book where [email protected]
End
這是C#代碼 公共的ActionResult埃德它(INT ID){
Author auth = new Author();
parhowDBEntities d=new parhowDBEntities();
var data = d.getAuthorBooks(9).ToList();
int x=data.Count;
ViewBag.AB = data;
Author auth2 = new Author();
auth2 = auth.GetEntity(id);
return View(auth2);
}
這是查看代碼
@foreach (var item in ViewBag.AB)
{
@item.BookName
}
我使用連接從多個表中獲取數據,所以這不適用於我。 –
所以你可以創建一個你需要的所有財產的模型,我的朋友。然後,可以輕鬆訪問。 – Tomato32