次のようなモデルがあります。
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.Foo3つのアイテムがあります。最初にマークされたポイントにヒットしasdf、3 つのアイテムがあります。次の行になると ( qwer)Fooは空です! の他のプロパティModelはまだあります。
なぜこれが起こるのか、どのように解決するのか考えていますか?
アップデート
これIEnumerableは、Linq と SQL の関連付けプロパティです。それが問題を引き起こしている可能性がありますか?