Hi all,
Today I try using NHibernate 1.2.0 and Castle, but meed this error: NHibernate.LazyInitializationException] - "Failed to lazily initialize a collection - no session"
I have to table Student and Class, an FK make relation Class with Student is 1 - N. I need to count number of student in one class. I use a page called classlist.aspx to show all class. It appears if I change to new page, all class and its number of student in page 1 is view ok.
I read and know function NHibernate.NHibernateUtil.IsInitialized() but it still was wrong if i use objClass.Students.Count to count student.
To make it work, I change value of property lazy like bellow:
Code:
<bag name="SchoolClasses" inverse="true" lazy="false" cascade="all-delete-orphan">xxx</bag>
But I think it is not good, it reduces performance of my web application.
Anyone was wrong on this? Would you have any suggestion please?
Thank u very much!