本文整理汇总了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);
}
示例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);
}
}
示例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);
}
}