モデル バインダーを Nhibernate で構成したい:
ので、私は持っています:
<object id="GigModelBinder" type="App.ModelBinders.GigModelBinder, App.Web" singleton="false" >
<property name="VenueManager" ref="VenueManager"/>
<property name="ArtistManager" ref="ArtistManager"/>
コントローラーのアクションをマークして、正しいモデル バインダーを使用する属性があります。
[AcceptVerbs("POST")]
public ActionResult Create([GigBinderAttribute]Gig gig)
{
GigManager.Save(gig);
return View();
}
これは正常に動作し、私の GigModelBinder には正しい VenueManger と ArtistManager が注入されています
ただし、アプリケーションの開始時に追加する場合:
System.Web.Mvc.ModelBinders.Binders.Add(typeof(App.Shared.DO.Gig), new GigModelBinder());
コントローラーアクションでは、次を使用します。
UpdateModel<Gig>(gig);
例えば:
[AcceptVerbs("POST")]
public ActionResult Update(Guid id, FormCollection formCollection)
{
Gig gig = GigManager.GetByID(id);
UpdateModel<Gig>(gig);
GigManager.Save(gig);
return View();
}
VenueManger と ArtistManager は GigModelBinder に挿入されていません。
私が間違っていることはありますか?