Пример #1
0
 /// <summary>
 /// ExtendMethod: 批量修改符合条件的实体对象的某些属性值
 /// </summary>
 /// <typeparam name="TEntity">实体类型</typeparam>
 /// <param name="dbOperator">实体数据操作对象</param>
 /// <param name="model">存储所有待修改的实体统一修改的属性值</param>
 /// <param name="entities">实体数据源</param>
 /// <returns>被修改值的实体元素数量</returns>
 public static int SetAll <TEntity>(this IDbOperator <TEntity> dbOperator, object model, IDbQuery <TEntity> entities)
     where TEntity : class
 {
     //非空检查
     Check.ArgumentNull(dbOperator, nameof(dbOperator));
     Check.ArgumentNull(model, nameof(model));
     Check.ArgumentNull(entities, nameof(entities));
     //执行批量修改
     return(dbOperator.SaveAll(ExtendDbOperator.GetSetParameters(model), entities));
 }
Пример #2
0
        /// <summary>
        /// ExtendMethod: 批量修改符合条件的实体对象的某些属性值
        /// </summary>
        /// <typeparam name="TEntity">实体类型</typeparam>
        /// <param name="dbOperator">实体数据操作对象</param>
        /// <param name="model">存储所有待修改的实体统一修改的属性值</param>
        /// <param name="predicates">修改条件表达式数组</param>
        /// <returns>被修改值的实体元素数量</returns>
        public static int SetAll <TEntity>(this IDbOperator <TEntity> dbOperator, object model, params Expression <Func <TEntity, bool> >[] predicates)
            where TEntity : class
        {
            //非空检查
            Check.ArgumentNull(dbOperator, nameof(dbOperator));
            Check.ArgumentNull(model, nameof(model));
            //获取待修改的实体数据源
            IDbQuery <TEntity> entities = dbOperator.Factory.CreateQuery <TEntity>().Filter(predicates);

            //执行批量修改
            return(dbOperator.SaveAll(ExtendDbOperator.GetSetParameters(model), entities));
        }