0

我有一个看起来像这样的模型:

public class MyModel
{
    public IEnumerable<AnotherClass> Foo { get; set; }
    // other properties go here
}

然后是这样的视图:

@model Asdf.MyModel

@{ Html.RenderAction("Partial", Model); } <!-- asdf: Model.Foo.Count == 3 -->
@{ Html.RenderAction("Partial", Model); } <!-- qwer: Model.Foo.Count == 0 -->

一个控制器,里面有这样的东西:

public ActionResult Partial(MyModel model)
{
    //do some things

    return this.View(model);
}

Partial.cshtml没有什么特别的

当我跑步时,Model.Foo里面有 3 个项目。首先,它击中标记的点asdf并具有 3 个项目。当它到达下一行时 ( qwer)Foo是空的!的其他属性Model仍然存在。

任何想法为什么会发生这种情况以及如何解决?


更新

IEnumerable是一个 Linq-to-SQL 关联属性。这会导致问题吗?

4

0 回答 0