public void Delete(Product product)
 {
     if (Context.Entry(product).State == EntityState.Detached)
     {
         Dbset.Attach(product);
     }
     Dbset.Remove(product);
 }
Exemple #2
0
        public Task <int> DeleteHash(int id)
        {
            var result = Dbset.Where(x => x.Id == id);

            Dbset.Remove(result.FirstOrDefault());
            Context.SaveChanges();
            return(null);
        }
Exemple #3
0
        public virtual void Delete(Expression <Func <T, bool> > where)
        {
            IEnumerable <T> objects = Dbset.Where <T>(where).AsEnumerable();

            foreach (T obj in objects)
            {
                Dbset.Remove(obj);
            }
        }
        public async Task DeleteAsync(int id)
        {
            var job = await GetAsync(id);

            if (job != null && job.IsFinished())
            {
                Dbset.Remove(job);
            }
        }
Exemple #5
0
        public async Task DeleteAsync(int id)
        {
            var record = await Dbset.FirstOrDefaultAsync(r => r.RuleSetId == id);

            if (record != null)
            {
                Dbset.Remove(record);
            }
        }
Exemple #6
0
        public virtual void DeleteAllForSeries(int seriesId, string userId)
        {
            var objects = Dbset.Where(x => x.UserId == userId && x.Comic.SeriesId == seriesId).ToList();

            foreach (var obj in objects)
            {
                Dbset.Remove(obj);
            }
        }
        public async Task DeleteAsync(int ruleId, int ruleSetId)
        {
            var entity = await Dbset.FirstOrDefaultAsync(e => e.RuleId == ruleId && e.RuleSetId == ruleSetId);

            if (entity != null)
            {
                Dbset.Remove(entity);
            }
        }
Exemple #8
0
        public virtual void Delete(Expression <Func <TEntity, bool> > @where, Action <TEntity> action)
        {
            var objects = Dbset.Where(where);

            foreach (TEntity entity in objects)
            {
                action(entity);
                Dbset.Remove(entity);
            }
        }
Exemple #9
0
        /// <summary>
        /// 删除单条数据
        /// </summary>
        /// <param name="id">实体编号</param>
        /// <exception cref="System.Data.Entity.Core.ObjectNotFoundException">entity</exception>
        public virtual void Delete(int id)
        {
            var entity = Get(m => m.Id == id);

            if (entity == null)
            {
                throw new ObjectNotFoundException("entity");
            }
            Dbset.Remove(entity);
        }
        public async Task DeleteAsync(int ruleSetId)
        {
            var records = await Dbset.Where(r => r.RuleSetId == ruleSetId).OrderBy(r => r.OrderId).ToListAsync();

            if (records != null)
            {
                foreach (var entity in records)
                {
                    Dbset.Remove(entity);
                }
            }
        }
Exemple #11
0
 public virtual void Delete(T entity)
 {
     Dbset.Remove(entity);
 }
Exemple #12
0
 public void Deletar(TEntity t)
 {
     Dbset.Remove(t);
     Context.SaveChanges();
 }
Exemple #13
0
 /// <summary>
 /// 根据id删除数据
 /// </summary>
 /// <param name="id"></param>
 public void Remove(Guid id)
 {
     Dbset.Remove(Dbset.Find(id));
 }