public virtual void Delete(TEntity entity) { using (BlogInDbContext context = new BlogInDbContext()) { context.Set <TEntity>().Attach(entity); context.Entry(entity).State = EntityState.Deleted; context.SaveChanges(); } }
public virtual void Create(TEntity entity) { using (BlogInDbContext context = new BlogInDbContext()) { context.Set <TEntity>().Attach(entity); context.Set <TEntity>().Add(entity); context.SaveChanges(); } }