asp.net-mvc – Windsor NHibernate ISession MVC
发布时间:2020-12-16 03:57:04 所属栏目:asp.Net 来源:网络整理
导读:我试图让Windsor为每个请求提供一个实例ISession,应该将其注入所有存储库 这是我的容器设置 container.AddFacilityFactorySupportFacility().Register( Component.ForISessionFactory().Instance(NHibernateHelper.GetSessionFactory()).LifeStyle.Singleton
我试图让Windsor为每个请求提供一个实例ISession,应该将其注入所有存储库
这是我的容器设置 container.AddFacility<FactorySupportFacility>().Register( Component.For<ISessionFactory>().Instance(NHibernateHelper.GetSessionFactory()).LifeStyle.Singleton,Component.For<ISession>().LifeStyle.Transient .UsingFactoryMethod(kernel => kernel.Resolve<ISessionFactory>().OpenSession()) ); //add to the container container.Register( Component.For<IActionInvoker>().ImplementedBy<WindsorActionInvoker>(),Component.For(typeof(IRepository<>)).ImplementedBy(typeof(NHibernateRepository<>)) ); 它基于这里的StructureMap帖子 但是,当运行它时,也会为它注入的每个对象创建一个新的Session.我错过了什么? (仅供参考NHibernateHelper,为Nhib设置配置) 解决方法
ISession应该有LifeStyle.PerWebRequest.但你可以使用
NHibernate facility而不是手动处理这些东西.
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net – 为什么Request.QueryString只读?
- ASP.NET Core中的依赖注入(vNext)
- asp.net-mvc-4 – 来自程序集’mscorlib的WebAPI RC’Syste
- 使用asp.net中的Enterprise Library实现日志文件
- 将webforms混合到ASP.NET MVC应用程序中的问题
- asp.net-mvc – 使用Data Annotation验证DateTime(日期和时
- .net – 尝试激活“MyDbContext”时无法解析“DatabaseConf
- asp.net – LinkBut??ton CommandName和CommandArgument
- 当从页面导航时页面加载错误时,asp.net – signalR中断
- asp.net-mvc – 用于ASP.NET MVC 3中用户帐户注册的Faceboo
推荐文章
站长推荐
- asp.net-mvc-routing – ASP.NET Core 1.0中的属
- asp.net-mvc – 将CSS添加到视图或部分视图
- ASP.NET标识会话超时
- asp.net – 用于登录用户到网站的T-SQL AES加密与
- asp.net-mvc – 将动态JSON对象传递给Web API –
- asp.net-mvc-2 – 使用ASP.NET MVC 2 C#4的最佳B
- asp.net – 什么设置的User.Identity.Name和User
- asp.net-mvc – 如何从asp.net MVC 4应用程序中的
- .NET Core多平台开发体验[3]: Linux (Windows Li
- ASP.NET会话性能
热点阅读