我在这里看到了几个关于处理和保持类似枚举值的最佳方法的问题/讨论(例如,坚持适用于枚举的数据,如何使用NHibernate保持枚举),我想问一般的共识是什么.
特别是:
注意:我将原本包含在此问题中的解释移到了答案中.
当我更新(使用flush)从数据库中检索的记录列表中的一条记录时,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();
}
Run Code Online (Sandbox Code Playgroud)
为什么nHibernate在没有更改时更新所有记录,如何阻止此行为?