/* * public virtual void Remove<T>(List<T> entity) where T : IEntity * { * WorkshopDBContext ctx = getContext(); * ctx.Set<T>().RemoveRange(entity); * } */ //public void Clear<T>() where T : IEntity //{ // ctx.Set<T>().RemoveRange(GetList<T>()); // ctx.ChangeTracker.DetectChanges(); // ctx.SaveChanges(); //} public virtual void Delete() { try { WorkshopDBContext ctx = getContext(); try { ctx.SaveChanges(); } catch (Exception e) { Logger.Log("error", logLevel.ERROR, e.Message); //do nothing } //ctx.Dispose(); //ctx = new WorkshopTestDBContext(); MurderAllConnections(ctx); ctx.Database.Delete(); try { ctx.SaveChanges(); } catch (Exception e) { Logger.Log("error", logLevel.ERROR, e.Message); //do nothing } DataAccessDriver.resetContext(); } catch (Exception e) { Logger.Log("error", logLevel.ERROR, e.Message); throw new WorkShopDbException(e.Message); } }
private WorkshopDBContext getContext() { return(DataAccessDriver.getContext()); }