isession

Nhibernate in asp,net ISession help

假装没事ソ 提交于 2019-12-24 06:24:17
问题 We're using nhibernate in and asp.net MVC application. We are implementing the Session per Request pattern, via a httpModule. It looks pretty straight forward, but when we run with NHibernate Profiler, it clearly shows that the sessions are never getting closed. the pattern seems straight forward...but I don't understand why the sessions are never closing. here's the code i think is important. set up the event handler: context.EndRequest += new EventHandler(this.context_EndRequest); in the

The factory was disposed and can no longer be used. NHibernatefacility

霸气de小男生 提交于 2019-12-23 09:36:30
问题 I have been trying for three days to figure out this NHibernatefacility thing with Castle and wcf and it's really getting frustrating. After solving a good dozen of errors, i have come to this one which seems pretty obvious but i can't solve. This is my global.asax's Application_Start container.AddFacility<AutoTxFacility>(); container.Register(Component.For<INHibernateInstaller>().ImplementedBy<NHibernateInstaller>()); container.AddFacility<NHibernateFacility>(); container.AddFacility

How to get NHibernate ISession to cache entity not retrieved by primary key

吃可爱长大的小学妹 提交于 2019-12-10 22:18:15
问题 My 'user' entity is almost always retrieved by username, rather than by its integer surrogate key. Because the username is not the primary key, this means that the ISession won't cache it and repeatedly hits the database to get the same data. Is there any way at all I can configure NHibernate to get the ISession to cache users retrieved by username? 回答1: It seems the answer is in fact no. Yes, if you're using the second level cache, no if you are using the Session cache. 回答2: Yes, you can use

What is the correct way to use Unit of Work/Repositories within the business layer?

左心房为你撑大大i 提交于 2019-11-30 20:30:59
Having built a small application using the Unit of Work/Repository pattern, I am struggling to understand how to use this properly within my business layer. My application has a a data access layer which can be either NHibernate or the Entity Framework. I can switch between these easily. I have a number of repositories, for example, Customer, Order etc. My unit of work will be either an ISession or an Object Context depending on which DAL I want to test with. My business layer contains a single business method - CreateOrder(). What I am struggling to understand is where in the business layer I

What is the correct way to use Unit of Work/Repositories within the business layer?

ぐ巨炮叔叔 提交于 2019-11-30 04:55:28
问题 Having built a small application using the Unit of Work/Repository pattern, I am struggling to understand how to use this properly within my business layer. My application has a a data access layer which can be either NHibernate or the Entity Framework. I can switch between these easily. I have a number of repositories, for example, Customer, Order etc. My unit of work will be either an ISession or an Object Context depending on which DAL I want to test with. My business layer contains a

Cyclic dependency with Castle Windsor IoC for NHibernate ISession

假装没事ソ 提交于 2019-11-29 11:50:12
I am using Castle Windsor for my IoC along with NHIbernate in an ASP.NET MVC app. It works great registered as follows (with one exception): container.Register(Component.For<ISessionFactoryBuilder.().ImplementedBy<SessionFactoryBuilder>().LifestyleSingleton()); // Register the NHibernate session factory as a singleton using custom SessionFactoryBuilder.BuildSessionFactory method. container.Register(Component.For<ISessionFactory>().UsingFactoryMethod(k => k.Resolve<ISessionFactoryBuilder>().BuildSessionFactory("ApplicationServices")).LifestyleSingleton()); container.Register(Component.For

Cyclic dependency with Castle Windsor IoC for NHibernate ISession

谁说我不能喝 提交于 2019-11-28 05:40:35
问题 I am using Castle Windsor for my IoC along with NHIbernate in an ASP.NET MVC app. It works great registered as follows (with one exception): container.Register(Component.For<ISessionFactoryBuilder.().ImplementedBy<SessionFactoryBuilder>().LifestyleSingleton()); // Register the NHibernate session factory as a singleton using custom SessionFactoryBuilder.BuildSessionFactory method. container.Register(Component.For<ISessionFactory>().UsingFactoryMethod(k => k.Resolve<ISessionFactoryBuilder>()