/// <summary> /// Update a row via id /// </summary> private static void UpdateRecord() { using (DESEDMEntities context = new DESEDMEntities()) { EntityKey key = new EntityKey("DESEDMEntities.DESContents", "Id", 2222); DESContent contentToUpdate = (DESContent)context.GetObjectByKey(key); Console.WriteLine(contentToUpdate.EntityState); if (contentToUpdate != null) { contentToUpdate.InputFileName = "Updated.txt"; context.SaveChanges(); } } }
/// <summary> /// Remove a row via id /// </summary> public static void RemoveRecord() { using (DESEDMEntities context = new DESEDMEntities()) { EntityKey key = new EntityKey("DESEDMEntities.DESContents", "Id", 2222); DESContent contentToDelete = (DESContent)context.GetObjectByKey(key); if (contentToDelete != null) { context.DeleteObject(contentToDelete); context.SaveChanges(); } } }