Is there an alternative to ISession.Merge() that doesn't throw when using optimistic locking?
问题 I've been trying to use ISession.Merge() to keep coherence between two sessions, but it fails when the merged instance has a higher Version property than the one loaded in the session (with a StaleObjectStateException). Is there an alternative method that would work when the Version fields do not match ? 回答1: Try calling: Session.Lock(string entityName, object obj, LockMode lockMode); with LockMode.Force. The remarks for that method state: This may be used to perform a version check