Brian Sullivan
Brian Sullivan

Reputation: 28563

Can I detach an object from an NHibernate session?

If I've gotten a persistent object from the database via NHibernate's Get() or Load() methods, is there a way for me to detach that object from its NHibernate session so that changes to it will not automatically be persisted?

Upvotes: 14

Views: 8677

Answers (1)

wtaniguchi
wtaniguchi

Reputation: 1324

Try Session's Evict method.

Changes to the instance will not be synchronized with the database. This operation cascades to associated instances if the association is mapped with cascade="all" or cascade="all-delete-orphan".

Upvotes: 17

Related Questions