NHibernate & Cancelling Changes to Entities
Posted
by user129609
on Stack Overflow
See other posts from Stack Overflow
or by user129609
Published on 2010-03-30T12:09:11Z
Indexed on
2010/03/30
12:13 UTC
Read the original article
Hit count: 330
Hi,
This seems like it would be a common issue to be but I don't know the best way to solve it. I want to be able to send an Entity to a view, have changes be made to the entity in the view, but then cancel (remove) those changes if the user cancels out of the view. What is the proper way to do this.
Here are two options I have but I think there should be others that are better
1) Take an entity, create a clone, send the clone to the view...if changes are accepted, update the original entity with the clone's values
2) Send the entity to the view, if the user cancels, remove the entity from NHibernate's cache and reload it from the database
For (2), the issue for me would be that the old entity could still be referenced throughout my project after it has been removed from the cache.
© Stack Overflow or respective owner