Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在休眠中使用 SaveOrUpdate 方法时有没有办法找到保存的项目。基本上,我需要知道一个项目是刚刚更新还是实际插入到一个会话中。
谢谢。
看看 NHibernate 拦截器。
实现 NHibernate 拦截器
拦截器
当您保存对象时,通常瞬态对象没有 Id,您可以创建一个列表,其中包含所有具有 Id 的处理对象。然后您可以迭代对象并找到具有新 ID 的对象 - 它们已被“保存”。