当我从数据库中检索的记录列表中更新(使用刷新)时,nHibernate将对原始列表中的所有记录进行版本控制。NHibernate更新未更改的记录
从数据库中检索的记录列表:
using(UnitOfWork.Start())
{
queuedJobs = aJobServiceManager.GetAllJobs().Where(aJob => aJob.Status == PricingStatus.QUEUED).ToList();
}
/* Do some work on the record*/
using(UnitOfWork.Start())
{
//aJob is a record from queuedJobs.
aJobServiceManager.Save(aJob);
//When Flush is called I'm expecting only aJob to be updated in the database.
//aJob is correctly updated BUT
//All the other records in queuedJobs are also updated (their version field is incremented).
UnitOfWork.Current.Flush();
}
为什么NHibernate的更新中的所有记录时,他们并没有改变,你如何制止这种行为?
UnitOfWork.Start()是否创建一个新的NHibernate会话? – 2010-07-14 16:19:03