简体   繁体   中英

NHibernate Lazy Loading Issue

Here are steps that i am doing 1) get all the entites to process the data 2) process each entity individually

ForEach Entity
   {       
     using (TransactionScope scope = new TransactionScope())
     {
             - Modify Entity
             - Modify Child objects //Childs can be accesed by Lazy loading
             - _sessionFactory.GetCurrentSession().Update(Entity);
             - _sessionFactory.GetCurrentSession().Flush(); 
             - scope.Complete();
     }
  }

So Once, process of one entity is done and started to process next entity at the time of Modify child objects throws lazy loading exception saying session got closed.

Can anyone please help me find the cause of this issue?

Thanks.

您不需要刷新任何东西,因为您已经在使用using语句,一旦范围超出范围,该对象将被清除。

由于第一个修改有效,所以我猜想存储库或作用域会关闭会话。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM