public void Save() { using (var context = new heroku_4f2def07091704cContext()) { dbSet = context.Set <TEntity>(); context.SaveChanges(); } }
public void Insert(TEntity entity) { using (var context = new heroku_4f2def07091704cContext()) { dbSet = context.Set <TEntity>(); dbSet.Add(entity); context.SaveChanges(); } }
public void Delete(object id) { using (var context = new heroku_4f2def07091704cContext()) { dbSet = context.Set <TEntity>(); TEntity entityToDelete = dbSet.Find(id); Delete(entityToDelete); context.SaveChanges(); } }
public void Update(TEntity entityToUpdate) { using (var context = new heroku_4f2def07091704cContext()) { dbSet = context.Set <TEntity>(); dbSet.Attach(entityToUpdate); context.Entry(entityToUpdate).State = EntityState.Modified; context.SaveChanges(); } }
public void SoftDelete(object id) { using (var context = new heroku_4f2def07091704cContext()) { dbSet = context.Set <TEntity>(); TEntity entityToUpdate = dbSet.Find(id); dbSet.Attach(entityToUpdate); context.Entry(entityToUpdate).CurrentValues["IsDeleted"] = 1; context.Entry(entityToUpdate).State = EntityState.Modified; context.SaveChanges(); } }
public void Delete(TEntity entityToDelete) { using (var context = new heroku_4f2def07091704cContext()) { dbSet = context.Set <TEntity>(); if (context.Entry(entityToDelete).State == EntityState.Detached) { dbSet.Attach(entityToDelete); } dbSet.Remove(entityToDelete); context.SaveChanges(); } }