Example #1
0
 public void Save()
 {
     using (var context = new heroku_4f2def07091704cContext())
     {
         dbSet = context.Set <TEntity>();
         context.SaveChanges();
     }
 }
Example #2
0
 public void Insert(TEntity entity)
 {
     using (var context = new heroku_4f2def07091704cContext())
     {
         dbSet = context.Set <TEntity>();
         dbSet.Add(entity);
         context.SaveChanges();
     }
 }
Example #3
0
 public void Delete(object id)
 {
     using (var context = new heroku_4f2def07091704cContext())
     {
         dbSet = context.Set <TEntity>();
         TEntity entityToDelete = dbSet.Find(id);
         Delete(entityToDelete);
         context.SaveChanges();
     }
 }
Example #4
0
        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();
            }
        }
Example #5
0
 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();
     }
 }
Example #6
0
        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();
            }
        }