After running the code bellow, the item.Name still says “New Item”.
what is wrong here?
item.Name = "Updated Item";
items.Update(item);
public void Update(Item item)
{
using (var context = new wirvar_masterEntities())
{
var key = new EntityKey("wirvar_masterEntities.Items", "ID", item.ID);
var itemToUpdate = (Item)context.GetObjectByKey(key);
if (itemToUpdate == null) return;
itemToUpdate = item;
context.SaveChanges();
}
}
To do this, try the
ApplyCurrentValuesmethod on the object context after doing yourGetObjectKey. Then all the values should update.