tags:

views:

28

answers:

1

on form i have two button cancel and save. when i modify the data in form after search and press save, its work fine and data saved. But when i press cancel and go to seach control its show the changed value (which i have cancel). My question is that how i can protect nhibernate to show only DB value not temperory content or cache?

you are right. But problem is that i have nothing doing on cancal button except of assigning panel to null i.e gpanel.Datacontext=null; actually issue is that when i searched the record from search control (by double click on record), all fields are populated. Now if change the content of any field/textbox and press cancell and open search window again it show the modification which is wrong. Did nhibernate perform this type of functionality? that he maintain the updated data himself. When I stop the application and run again it show the actually DB value not that list time. please help Can you guide me clone functionality and implementation if that help in this issue.

A: 

It seems that you are storing data in your object before making sure that user wants to save it.If that's the case I think instead of disabling NHibernate cache you should think of a better approach to get data from user. For example if user is providing some information about a product I would do as follows :

public void SaveButtonClicked(object sender,EventArgs e)
{
this.Product.Name=txtName.Text;
this.Product.Category=(Category)cboCategroy.SelectedItem;
this.Session.SaveOrUpdate(this.Product);
this.Session.Flush();
}

Since until SaveButton is clicked no data is saved in Product if user clicks cancel he will see the original data of product.

Beatles1692