在从存储过程 MVC-4 获取的视图中显示记录列表

Display Records List in View Obtained from Stored Procedure MVC-4

我正在尝试显示通过存储过程从数据库中获取的记录列表,

我无法在 mvc-4 应用程序中列出视图中的记录。

这是现有的代码

   public ActionResult Report_OrderAnalysisDetail(string Status)
        {
               var AnalysisDetail= db.Report_OrderAnalysisDetail(0,25,0,null,null,null,null,null,Status,null);

               return View(AnalysisDetail);
        }

这里是完整视图:

@model IList<Agorz_MVCApplication.Models.Report_OrderAnalysisDetail_Result>
<div class="content-wrapper" style="min-height: 1000px;">
    <section class="content-header">
        <h1 class="page-header">Order Analysis Detail</h1>
    </section>
    <div id="RenderPartial" name="RenderPartial" style="min-height:950px;important">
        @Html.Partial("_Report_OrderAnalysisDetail")

    </div>
</div>

这是我要在其中迭代记录的部分视图:

@model IList<Agorz_MVCApplication.Models.Report_OrderAnalysisDetail_Result>
  @foreach (var item in Model)
    {
        <tr class="gradeX odd" role="row">

            <td class="center">@item.OrderId</td>
            <td class="center">@if(item.OrderDate!=null){@item.OrderDate.Value.ToShortDateString()}</td>
            <td class="center">@item.ServiceRequested</td>
            <td class="center">@item.ServiceProvider</td>
            <td class="center">@item.Customer</td>
            <td class="center">@item.OrderStatus</td>
            
        </tr>
    }

当我 运行 加载代码和视图时,出现以下错误。

Server Error in '/' Application.

The model item passed into the dictionary is of type 'System.Data.Objects.ObjectResult'1[Agorz_MVCApplication.Models.Report_OrderAnalysisDetail_Result]', but this dictionary requires a model item of type 'System.Collections.Generic.IList'1[Agorz_MVCApplication.Models.Report_OrderAnalysisDetail_Result]'.

var AnalysisDetail= db.Report_OrderAnalysisDetail(0,25,0,null,null,null,null,null,Status,null).ToList();

在末尾添加 ToList() 作为 sp returns 一个对象,并且您在视图中提供了一个列表类型