Exemple #1
0
        /// <summary>
        /// 删除实体
        /// </summary>
        /// <param name="whereCondition"></param>
        /// <returns></returns>
        public virtual int DeleteByCondition(Expression <Func <TEntity, bool> > whereCondition)
        {
            Specification <TEntity> specification = ExpressionSpecification <TEntity> .Eval(whereCondition);

            IList <TEntity> col = this.GetByCondition(specification);

            this._dbContext.Set <TEntity>().RemoveRange(col);
            col.ToList().ForEach(t =>
            {
                this._dbContext.Entry <TEntity>(t).State = EntityState.Deleted;
            });
            return(this._dbContext.SaveChanges());
        }