public static string MakeUpdateStatement(string table, IDictionary<string, object> whereCols,
IDictionary<string, object> columns, IList<object> sqlParams)
{
// Create the string list of columns to update (and put the matching values in sqlParams).
StringBuilder sb = DbCaches.StringBuilders.Get();
sb.Append("UPDATE ");
sb.Append(table);
sb.Append(" SET ");
bool first = true;
foreach (string key in columns.Keys)
{
if (!first)
{
sb.Append(", ");
}
else
{
first = false;
}
sb.Append(key);
sb.Append(" = ?");
object val = columns[key];
sqlParams.Add(val);
}
// Create the string list of where clauses (and put the matching values in sqlParams).
sb.Append(MakeWhereClause(whereCols, sqlParams));
string retVal = sb.ToString();
DbCaches.StringBuilders.Return(sb);
return retVal;
}