Exemple #1
0
        /// <summary>
        ///  批量修改
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="t"></param>
        /// <param name="cols">选择性修改的字段</param>
        /// <param name="whereCols">修改的条件 可以是字段也可是  字段 逗号隔开的字段</param>
        /// <returns></returns>
        public bool UpdateBatch <T>(List <T> list, string cols, string whereStr, WhereType whereType)
        {
            List <CommandInfo> commandInfos = new List <CommandInfo>();

            if (list == null || list.Count <= 0)
            {
                return(false);
            }
            CommandInfo commandInfo = null;
            SqlModel    updateModel = null;

            for (int i = 0; i < list.Count; i++)
            {
                updateModel = CreateSqlHelper.UpdateSql(list[i], cols, whereStr, whereType);

                commandInfo = new CommandInfo()
                {
                    CommendText = updateModel.Sql,
                    IsProcess   = false,
                    Params      = updateModel.SqlParameters
                };
                commandInfos.Add(commandInfo);
            }
            return(SQLiteHelper.ExecuteTrans(commandInfos));
        }
Exemple #2
0
        /// <summary>
        ///  修改
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="t"></param>
        /// <param name="cols">选择性修改的字段</param>
        /// <param name="whereCols">修改的条件 可以是字段也可是  字段 逗号隔开的字段</param>
        /// <returns></returns>
        public int Update <T>(T t, string cols, string whereCols, WhereType whereType, bool needReturn)
        {
            if (t == null)
            {
                return(0);
            }

            SqlModel updateModel = CreateSqlHelper.UpdateSql(t, cols, whereCols, whereType);

            return(SQLiteHelper.ExecuteNonQuery(updateModel.Sql, needReturn, updateModel.SqlParameters));
        }