将数据模型传递给视图的问题

时间:2011-04-26 09:57:53

标签: asp.net-mvc-3

我认为这是“索引”:

<ul>
@foreach (var r in Model.Where(c => c.id_parent == null)) {
    <li>
        @Html.DisplayFor(i => r.node.name)
        @if (r.node.children.Count > 0) { 
        <ul>
            @{Html.RenderPartial("aView", r.node);}
        </ul>
        }
    </li>
}
</ul>

但是在RenderPartial行上出现此错误:

    The model item passed into the dictionary is of type 'System.Data.Entity.DynamicProxies.arrangement_86479E2FE1ED6F9584881D169E310F3C37120A10A806A6CF640967CBCB017966',
but this dictionary requires a model item of type
'System.Collections.Generic.IEnumerable`1[PlanovaniZdroju.Models.arrangement]'.

如何将r.node重新键入IEnumerable?或者我怎么解决它?

1 个答案:

答案 0 :(得分:0)

你确定你不是故意的:

<ul>
    @{Html.RenderPartial("aView", r.node.children);}
</ul>