Hello,
I am implementing an ObservableCollection to manage my EF entities. When i want to edit some entity, i create a clone of the entity and i open it up inside a popup window. When the user finishes to edit the cloned entity, i proceed to detach the original entity and then attach the new (cloned and edited) entity.
No exception occurs, but no update occurs to the db.
Here is the method that performs the update. It is an override of the ObservableCollection SetItem method :
protected override void SetItem(int index, T item)
{
T oldItem = Items.ElementAt(index);
base.SetItem(index, item);
try
{
ContextManager.CurrentObjectContext.Detach(oldItem);
ContextManager.CurrentObjectContext.Attach((IEntityWithKey)item);
ContextManager.CurrentObjectContext.SaveChanges();
}
catch (Exception err)
{
base.SetItem(index, oldItem);
MessageBox.Show(err.Message);
}
}
Will greatly appriciate any help...
Thanks in advance, Oran