/// <summary> /// Marks record for deleting. /// </summary> /// <param name="toDelete"></param> private static bool DeleteWithoutSubmitting(EntityObject toDelete, ProjectPropertiesEntities db) { if (db.Connection.State != System.Data.ConnectionState.Open) { db.Connection.Open(); } try { db.DeleteObject(toDelete); return true; } catch (Exception e) { return false; } finally { } }
//==================================================================================DELETE===========================================================================================// /// <summary> /// Deletes record from db. /// </summary> /// <param name="toDelete"></param> /// <exception cref="ConnectionException" /> internal static void Delete(EntityObject toDelete) { ProjectPropertiesEntities db = new ProjectPropertiesEntities(); if (db.Connection.State != System.Data.ConnectionState.Open) { db.Connection.Open(); } try { db.DeleteObject(toDelete); db.SaveChanges(); } catch (Exception e) { throw new ConnectionException(e); } finally { } }