Exemplo n.º 1
0
        public void AddUp()
        {
            if (((IQueueTable)Queue).ExpAssign == null || ((IQueueTable)Queue).ExpAssign.Count == 0)
            {
                throw new Exception("赋值的参数不能为空!");
            }
            Queue.Sql = new StringBuilder();
            var strWhereSql = Visit.Where(Queue.ExpWhere);

            if (!string.IsNullOrWhiteSpace(strWhereSql))
            {
                strWhereSql = "WHERE " + strWhereSql;
            }

            #region 字段赋值
            var sqlAssign = new StringBuilder();
            foreach (var keyValue in ((IQueueTable)Queue).ExpAssign)
            {
                var strAssemble = Visit.Assign(keyValue.Key);
                var strs        = strAssemble.Split(',');
                foreach (var s in strs)
                {
                    sqlAssign.AppendFormat("{0} = {0} + {1},", s, keyValue.Value);
                }
            }
            if (sqlAssign.Length > 0)
            {
                sqlAssign = sqlAssign.Remove(sqlAssign.Length - 1, 1);
            }
            #endregion

            Queue.Sql.AppendFormat("UPDATE {0} SET {1} {2}", Query.DbProvider.KeywordAegis(TableName), sqlAssign, strWhereSql);
        }
Exemplo n.º 2
0
        public void Update(TEntity entity)
        {
            Queue.Sql = new StringBuilder();
            var strWhereSql = Visit.Where(Queue.ExpWhere);
            var strAssemble = Visit.Assign(entity);

            if (!string.IsNullOrWhiteSpace(strWhereSql))
            {
                strWhereSql = "WHERE " + strWhereSql;
            }

            Queue.Sql.AppendFormat("UPDATE {0} SET {1} {2}", Query.DbProvider.KeywordAegis(TableName), strAssemble, strWhereSql);
        }