在ASP.NET MVC3應用程序中,我的控制器將使用BL「管理」類的集合,而後者將使用存儲庫。這些存儲庫依靠EF DbContext實例來執行其職責。實例化存儲庫實例中的DbContext
我打算配置IoC容器做了依賴注入下面的方式(數據模塊)
Bind<StoreContext>().ToSelf().InRequestScope();
Bind<ICatUserRepository>().To<GenericUserRepository>().InRequestScope();
StoreContext
是一個DbContext
。它是構造函數注入到GenericUserRepository
。 這種方式,我假設,the rule of my DbContext to be instantiated in also PerRequest將保持完成,對吧?