2013/3/14 Atilla İlhan KARTAL <[email protected]>: > Dear All; > > We are using NHibernate in a C# Winform application. But we are facing a > problem: > > 1- We are listing all the users (records) into a grid > 2- When doubled clicked on a user record, we are opening another form in > order to edit user properties > 3- We are binding properties to text boxes and other controls using > BindingSource component > 4- When a property is changed in a textbox, the related record in the grid > is changed, too, even if object is not saved explicitly. This is our problem > because we don't want the changes in edit form to be reflected on the grid > immediately. > > What we have tried till now: > 1- When transferring object from grid to edit form, we are not passing the > object itself but a copy of it using Session.Load<M>(id); command
There is no copy here. The session will never hand out two different .net object instances that actually represent the same entity (i.e. same type and primary key). (This is the first-level cache.) > 2- We are evicting the returned object using Session.Evict(o) command Evicting it from the session will not prevent other parts of your GUI that already have a reference to the object from seeing changes. (Evict() then Load() will get you two separate instances.) You might want to consider reloading the object in a separate session used for the edit scenario. When the edit is complete, you refresh the object in the grid's session. /Oskar -- You received this message because you are subscribed to the Google Groups "nhusers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/nhusers?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
