This may not be the best place to bring this up, but... It seems like there is a little bit of confusion to be found in the docs / forums about how one reconnects an entity object to a new ISession. Some places recommend Lock() with LockMode.None, and other places call for SaveOrUpdate(). As nearly as I can tell, one should use the Lock() method only if you can be absolutely sure that the entity object in question has not been modified since it was detached, and that the database representation of that object has also not been changed (i.e. it's not stale). But how can you be sure of that, in an environment with even a little concurrency? That doesn't seem like a safe assumption to make, so I've been using SaveOrUpdate() pretty much all the time. Am I confused?
|