0
一個觀點我使用.NET 4.0,MVC3和Entity Framework 4.0通過歷史使用實體框架
我需要鍵入「聲明」的數據庫記錄傳遞給視圖。來獲取該記錄的代碼如下:
public ActionResult pdfStatement(string InvoiceNumber)
{
ObjectParameter[] parameters = new ObjectParameter[1];
parameters[0] = new ObjectParameter("InvoiceNumber", InvoiceNumber);
return View(_db.ExecuteFunction<Models.Statement>("uspInvoiceStatement", parameters));
}
其中「uspInvoiceStatement」是用來獲取「聲明」
我創建了接收「聲明」
一個強類型的視圖我的存儲過程< % @ Page Language="C#" Inherits="System.Web.Mvc.ViewPage <InvoiceSearch.Models.Statement>" %>
當我運行該應用程序我得到一個異常說
"The model item passed into the dictionary is of type 'System.Data.Objects.ObjectResult`1[InvoiceSearch.Models.Statement]',
but this dictionary requires a model item of type 'InvoiceSearch.Models.Statement'.
幫助我擺脫這種麻煩。 「