Is there a way to use an NHibernate session to find out if changes need to be written to db?

I am using NHibernate here with C #. I have a cache of nhibernate objects that have lazily loaded objects inside those that may have changes written for them. I need a way to determine if there are changes that need to be saved. It’s quite a lot of effort for setting flags when one little thing changes, and it’s also quite annoying to compare the cache with a copy of the original (due to lazy loading).

Just wondering if there is a way I can use the current session object to find out if there are pending changes that need to be written to db, that means I can get the “do you want to save” prompt if changes actually occur . I can not autosave, the client requires a save button.

+3
source share
1 answer

NHibernate.ISessionprovides a method IsDirty()so you can verify this.

+2
source

Source: https://habr.com/ru/post/1752156/


All Articles