當我從數據庫中檢索的記錄列表中更新(使用刷新)時,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