Can I prevent nhibernate creating new ISessions when lazy loading? How?
Correction: I mean new IDbConnections. I have implemented my own DriverConnectionProvider and I see it gets called due to lazy loading
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you are using NHibernate as a connection manager and sql generator. I.e. you have a lot of code like the following:
Then you cannot use lazy loading. So you will need to disable lazy loading. This can be most easily achieved by specifying
default-lazy="false"on your hibernate-mapping taghttp://nhibernate.info/doc/nh/en/index.html#mapping-declaration-mapping
I might recommend using an IStatelessSession instead of the default ISession as well. Keep in mind that this is not the recommended use of NHibernate.