私は次の設定をしています
public class Profile
{
//Some Properties
//Some Methods
}
/*Model Class*/
public class LineItem
{
public Profile Profile {get;set;}
}
私のコントローラーで。次の2つのアクションがあります
public ActionResult GetRequest(){
LineItem model = new LineItem();
model.Profile = new Profile(){/*Initialize Properties*/};
return View(model);
}
public ActionResult PostRequest(LineItem item(){
item.Profile .... /*Profile Is Null*/
return View(...);
}
LineItemモデルクラスのProfileプロパティがGetRequestで設定され、ビューに返されることを確認しましたが、そのモデルが送信されたときにその複雑なプロパティを永続化する方法を知りたいです。人々は通常、モデルの永続化に非表示のフィールドを使用し、セッションも利用できることを知っていますが、モデルの複雑なプロパティを永続化するようにModelBinderに時々(おそらく属性またはアノテーションを介して)指示できるはずです。
これはどのように行うことができますか?