public virtual int Delete(TKey key, bool isSave = true)
        {
            TEntity entity = EFContext.Set <TEntity, TKey>().Find(key);

            EFContext.RegisterDeleted <TEntity, TKey>(entity);
            return(isSave ? EFContext.Submit() : 0);
        }
Example #2
0
        public int DeleteByCondition(System.Linq.Expressions.Expression <Func <T, bool> > predicate, bool isCommit = true)
        {
            var list = Entities.Where(predicate);

            EFContext.RegisterDeleted(list);
            return(isCommit ? EFContext.Commit() : 0);
        }
Example #3
0
        /// <summary>
        /// 删除多个
        /// </summary>
        /// <param name="id"></param>
        /// <param name="isSave"></param>
        /// <returns></returns>
        public virtual int Delete(int[] id, bool isSave = true)
        {
            var entityList = EFContext.Set <TEntity>().Where(p => id.Contains(p.Id));

            foreach (var item in entityList)
            {
                EFContext.RegisterDeleted(item);
            }
            return(isSave ? EFContext.Commit() : 0);
        }
Example #4
0
        /// <summary>
        ///     删除实体记录集合
        /// </summary>
        /// <param name="entities"> 实体记录集合 </param>
        /// <param name="isSave"> 是否执行保存 </param>
        /// <returns> 操作影响的行数 </returns>
        public virtual OperationResult Delete(IEnumerable <TEntity> entities, bool isSave = true)
        {
            PublicHelper.CheckArgument(entities, "entity");
            OperationResult operationResult = new OperationResult(OperationResultType.Success);

            EFContext.RegisterDeleted(entities);
            int number = isSave ? EFContext.Commit() : 0;

            operationResult.Message    = "删除成功:" + number + "条数据";
            operationResult.AppendData = number;
            return(operationResult);
        }
Example #5
0
 /// <summary>
 ///     删除实体记录集合
 /// </summary>
 /// <param name="entities"> 实体记录集合 </param>
 /// <param name="isSave"> 是否执行保存 </param>
 /// <returns> 操作影响的行数 </returns>
 public virtual int Delete(IEnumerable <TEntity> entities, bool isSave = true)
 {
     if (entities != null && entities.Count() > 0)
     {
         //PublicHelper.CheckArgument(entities, "entities");
         EFContext.RegisterDeleted(entities);
         return(isSave ? EFContext.Commit() : 0);
     }
     else
     {
         return(0);
     }
 }
Example #6
0
 /// <summary>
 ///     删除实体记录集合
 /// </summary>
 /// <param name="entities"> 实体记录集合 </param>
 /// <param name="saveNow"> 是否执行保存 </param>
 /// <returns> 操作影响的行数 </returns>
 public virtual int Delete(IEnumerable <TEntity> entities, bool saveNow = true, bool validateOnSaveEnabled = true)
 {
     PublicHelper.CheckArgument(entities, "entities");
     EFContext.RegisterDeleted <TEntity, TKeyType>(entities);
     return(saveNow ? EFContext.Commit(validateOnSaveEnabled) : 0);
 }
Example #7
0
 /// <summary>
 ///     删除实体记录
 /// </summary>
 /// <param name="entity"> 实体对象 </param>
 /// <param name="saveNow"> 是否执行保存 </param>
 /// <returns> 操作影响的行数 </returns>
 public virtual int Delete(TEntity entity, bool saveNow = true, bool validateOnSaveEnabled = true)
 {
     PublicHelper.CheckArgument(entity, "entity");
     EFContext.RegisterDeleted <TEntity, TKeyType>(entity);
     return(saveNow ? EFContext.Commit() : 0);
 }
Example #8
0
 /// <summary>
 ///     删除实体记录
 /// </summary>
 /// <param name="entity"> 实体对象 </param>
 /// <param name="isSave"> 是否执行保存 </param>
 /// <returns> 操作影响的行数 </returns>
 public virtual DataResult Delete(TEntity entity, bool isSave = true)
 {
     EFContext.RegisterDeleted <TEntity, TKey>(entity);
     return(isSave ? EFContext.Commit() : null);
 }
 public virtual int Delete(IEnumerable <TEntity> entities, bool isSave = true)
 {
     EFContext.RegisterDeleted <TEntity, TKey>(entities);
     return(isSave ? EFContext.Submit() : 0);
 }
 public virtual int Delete(TEntity entity, bool isSave = true)
 {
     EFContext.RegisterDeleted <TEntity, TKey>(entity);
     return(isSave ? EFContext.Submit() : 0);
 }
 /// <summary>
 ///     删除实体记录
 /// </summary>
 /// <param name="entity"> 实体对象 </param>
 /// <param name="isSave"> 是否执行保存 </param>
 /// <returns> 操作影响的行数 </returns>
 public virtual bool Remove(T entity, bool isSave = true)
 {
     EFContext.RegisterDeleted(entity);
     return(isSave && EFContext.Commit() > 0);
 }
Example #12
0
 public int Delete(IEnumerable <TEntity> entities, bool isSave = true)
 {
     EFContext.RegisterDeleted(entities);
     return(isSave ? EFContext.Commit() : 0);
 }
Example #13
0
 /// <summary>
 ///     删除实体记录
 /// </summary>
 /// <param name="entity"> 实体对象 </param>
 /// <param name="isSave"> 是否执行保存 </param>
 /// <returns> 操作影响的行数 </returns>
 public int Delete(TEntity entity, bool isSave = true)
 {
     PublicHelper.CheckArgument(entity, "entities");
     EFContext.RegisterDeleted(entity);
     return(isSave ? EFContext.Commit() : 0);
 }
Example #14
0
 /// <summary>
 ///     删除实体记录
 /// </summary>
 /// <param name="entity"> 实体对象 </param>
 /// <param name="isSave"> 是否执行保存 </param>
 /// <returns> 操作影响的行数 </returns>
 public virtual int Delete(TEntity entity, bool isSave = true)
 {
     PublicHelper.CheckArgument(entity, "entity");
     EFContext.RegisterDeleted <TEntity, TKey>(entity);
     return(isSave ? EFContext.Commit() : 0);
 }
Example #15
0
 /// <summary>
 ///     删除实体记录集合
 /// </summary>
 /// <param name="entities"> 实体记录集合 </param>
 /// <param name="isSave"> 是否执行保存 </param>
 /// <returns> 操作影响的行数 </returns>
 public virtual int Delete(IEnumerable <TEntity> entities, bool isSave = true)
 {
     Check.NotNull(entities, "entities");
     EFContext.RegisterDeleted(entities);
     return(isSave ? EFContext.Commit() : 0);
 }
Example #16
0
 /// <summary>
 ///     删除实体记录
 /// </summary>
 /// <param name="entity"> 实体对象 </param>
 /// <param name="isSave"> 是否执行保存 </param>
 /// <returns> 操作影响的行数 </returns>
 public virtual int Delete(TEntity entity, bool isSave = true)
 {
     Check.NotNull(entity, "entity");
     EFContext.RegisterDeleted(entity);
     return(isSave ? EFContext.Commit() : 0);
 }
Example #17
0
 /// <summary>
 ///     删除实体记录
 /// </summary>
 /// <param name="entity"> 实体对象 </param>
 /// <param name="isSave"> 是否执行保存 </param>
 /// <returns> 操作影响的行数 </returns>
 public virtual int Delete(TEntity entity, bool isSave = true)
 {
     Argument.NullParam(entity, entity.GetType().Name);
     EFContext.RegisterDeleted(entity);
     return(isSave ? EFContext.Commit() : 0);
 }
 /// <summary>
 ///     删除实体记录集合
 /// </summary>
 /// <param name="entities"> 实体记录集合 </param>
 /// <param name="isSave"> 是否执行保存 </param>
 /// <returns> 操作影响的行数 </returns>
 public virtual int Remove(IEnumerable <T> entities, bool isSave = true)
 {
     EFContext.RegisterDeleted(entities);
     return(isSave ? EFContext.Commit() : 0);
 }
Example #19
0
 /// <summary>
 ///     删除实体记录集合
 /// </summary>
 /// <param name="entities"> 实体记录集合 </param>
 /// <param name="isSave"> 是否执行保存 </param>
 /// <returns> 操作影响的行数 </returns>
 public virtual int Delete(IEnumerable <TEntity> entities, bool isSave = true)
 {
     PublicHelper.CheckArgument(entities, "entities");
     EFContext.RegisterDeleted <TEntity, TKey>(entities);
     return(isSave ? EFContext.Commit() : 0);
 }
Example #20
0
 public int Delete(TEntity entity, bool isSave = true)
 {
     EFContext.RegisterDeleted(entity);
     return(isSave ? EFContext.Commit() : 0);
 }