I've seen this question a few times, generally answered with 'the session has been closed so you need to open it'
In this scenario - Class Order { int Id IList<Item> Items; } Class Item { int Id string Name; }
if All Orders are loaded IList<Order> itemList; using(ISession session = _sessionFactory.OpenSession()) { ICriteria targetObjects = _session.CreateCriteria(typeof(Order)); itemList = targetObjects.List<Order>(); } and the Items are Lazy Loaded Then having the following itemList[0].Items[0].Name will result in an exception - failed to lazily initialize a collection of role....
Is there a way to configure the Mapping File, maybe using a Proxy, so that the Session is Automatically Opened to load the Items for that Order when accessed?
thanks
|