I have a service object that is responsible for some business logic validation. What he does, before going to the Update to Repository repository, checks if the object he is working on complies with some business rules.
One of these rules that must be checked is that the Object Status property has not changed compared to the entity in the database. Since I use repositories that use the same ISession when I try to get an entity from a database to get an object for comparison:
if (fromDbEntity.Status != entity.Status) throw new Exception("Cannot change status...");
I always get fromDbEntity , which is in the 1st level cache, so I am working on the same object.
Is there a way to force NHibernate / Repository to retrieve an object from the database, even if it is already in the session scope?
source share