I add data in an ObjectSet and did SaveChanges on ObjectContext. But the new data does not shown in the DataGrid!
Code:
bsWork.DataSource = Program.EC.Addresses; ... Address newAdr = new Address(); //change properties newAdr ... Program.EC.Addresses.AddObject(newAdr); Program.EC.SaveChanges(SaveOptions.AcceptAllChangesAfterSave);
How to refresh data or view new data?
UPD: Solution
... bsWork.Add(newAdr); Program.EC.SaveChanges(SaveOptions.AcceptAllChangesAfterSave); ...
I hope this code may helpful for you.
try { // Try to save changes, which may cause a conflict. int num = context.SaveChanges(); Console.WriteLine("No conflicts. " + num.ToString() + " updates saved."); } catch (OptimisticConcurrencyException) { // Resolve the concurrency conflict by refreshing the // object context before re-saving changes. context.Refresh(RefreshMode.ClientWins, orders);}