nHibernate performance issue when loading large collections

后端 未结 3 1227
没有蜡笔的小新
没有蜡笔的小新 2020-12-12 02:37

(just to make clear: my app isn\'t really about employees and departments. I just use these terms for example\'s sake).
Each department has an employees collection, whic

3条回答
  •  渐次进展
    2020-12-12 03:18

    There is no reason for you to load all the empoyees to memory. you should write a query using HQL/Critiria API/Linq to NHibernate to check if the employee already existing in the DB. for example:

    var existingEmpoyee = session.Query()
                                 .Where(e => e.Equals(newEmployee))
                                 .FirstOrDefault();
    if(existingEmployee != null)
       // Insert new employee to DB
    

提交回复
热议问题