当前位置: 首页>>代码示例>>C#>>正文


C# StringBuffer.AppendFormat方法代码示例

本文整理汇总了C#中StringBuffer.AppendFormat方法的典型用法代码示例。如果您正苦于以下问题:C# StringBuffer.AppendFormat方法的具体用法?C# StringBuffer.AppendFormat怎么用?C# StringBuffer.AppendFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在StringBuffer的用法示例。


在下文中一共展示了StringBuffer.AppendFormat方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetField

        public override BaseHelper GetField(Dictionary<string , object> wheres, QueryObj query, string whichColumn = null)
        {
            string showCols = whichColumn ?? CurrentTable.PrimaryKey;

            if (!CurrentTable.Columns.ContainsKey(whichColumn))
                return End(string.Empty, string.Empty);

            StringBuffer orderBySql = string.IsNullOrEmpty(query.SortOn) ? string.Empty : (" Order By " + query.SortOn);

            WhereCondition which = MakeWhere(wheres);

            var sql = new StringBuffer();//"Select " + showCols + " FROM " + CurrentTable.Name + which.WhereSql + orderBySql + " ;";
            sql.AppendFormat("SELECT {0} FROM {1} {2} {3};" , showCols , CurrentTable.Name, which.WhereSql , orderBySql);
            //HttpContext.Current.Response.Write("<hr>"+sql +  "<hr><hr>");
            //return this;

            object objVal = dac.ExecuteScalar(sql, which.Params);

            return End(objVal, sql);
        }
开发者ID:rpdg,项目名称:cSharpSqlBuilder,代码行数:20,代码来源:SqlServer.cs

示例2: Set

        /// <summary>
        /// Update
        /// </summary>
        /// <param name="updated"></param>
        /// <param name="wheres"></param>
        /// <returns></returns>
        public override BaseHelper Set(Dictionary<string , object> updated, Dictionary<string , object> wheres)
        {
            Dictionary<string , Column> cols = CurrentTable.Columns;

            StringBuffer _valueNames = string.Empty ;
            List<SqlParameter> _parameters = new List<SqlParameter>();

            foreach (KeyValuePair<string, Column> kv in cols) {
                string colName = kv.Key;
                Column col = kv.Value;

                //在传入obj中存在数据
                if (updated.ContainsKey(colName)) {

                    SqlParameter param = makeParam(col, updated[colName]);
                    _parameters.Add(param);

                    _valueNames += colName + "=" + param.ParameterName + "," ;
                }
            }

            WhereCondition whereObj = MakeWhere(wheres);

            //合并2个params
            int n = _parameters.Count;
            int m = whereObj.Params.Length;
            SqlParameter[] paramx = new SqlParameter[n + m];
            _parameters.CopyTo(paramx);
            whereObj.Params.CopyTo(paramx, n);

            StringBuffer sql = new StringBuffer();//"Update " + Schema + CurrentTable.Name + " Set " + _valueNames.ToString(0, _valueNames.Length - 1) + " " + whereObj.WhereSql + " ; ";
            sql.AppendFormat("UPDATE {0}{1} SET {2} {3} ;" , Schema , CurrentTable.Name , _valueNames.ToString(0, _valueNames.Length - 1) , whereObj.WhereSql);

            //			HttpContext.Current.Response.Write("<hr>"+sql +  "<hr>"+paramx.Length+"<hr>");
            //			for (int i = 0; i < paramx.Length ; i++){
            //				HttpContext.Current.Response.Write("<hr>"+paramx[i].ParameterName +  "<hr>"+paramx[i].Value+"<hr>");
            //			}
            //			return this;

            if (inTrans)
                return SetTrans(sql, paramx);
            else {
                int v = dac.ExecuteNonQuery(sql, paramx);
                return End(v, sql);
            }
        }
开发者ID:rpdg,项目名称:cSharpSqlBuilder,代码行数:52,代码来源:SqlServer.cs

示例3: Del

        /// <summary>
        /// Delete
        /// </summary>
        /// <param name="wheres"></param>
        /// <returns></returns>
        public override BaseHelper Del(Dictionary<string , object> wheres)
        {
            if (wheres == null)
                throw new InvalidExpressionException("Error: 'WHERE' condition can't be null.");

            WhereCondition whereObj = MakeWhere(wheres);
            var sql = new StringBuffer();
            sql.AppendFormat("Delete From {0}{1} {2};", Schema , CurrentTable.Name , whereObj.WhereSql);

            if (inTrans)
                return SetTrans(sql, whereObj.Params);
            else {
                int v = dac.ExecuteNonQuery(sql, whereObj.Params);
                return End(v, sql);
            }
        }
开发者ID:rpdg,项目名称:cSharpSqlBuilder,代码行数:21,代码来源:SqlServer.cs


注:本文中的StringBuffer.AppendFormat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。