public static string BuildUpdate(KeyValueListBase liste, string where) { var sb = new StringBuilder(); sb.Append("UPDATE " + liste.TableName + " SET "); AppendKeyValuePairs(sb, liste.Pairs, ", "); sb.Append(" WHERE "); sb.Append(where); return sb.ToString(); }
public static string BuildInsert(KeyValueListBase liste) { var pairs = liste.Pairs; var count = pairs.Count; // create the basic statement var sb = PrepareInsertBuilder(liste); // append values sb.Append("("); for (var i = 0; i < count; i++) { var pair = pairs[i]; sb.Append(GetValueString(pair.Value)); if (i < count - 1) { sb.Append(","); } } sb.Append(")"); return sb.ToString(); }
public void Delete(KeyValueListBase list) { ExecuteComand(SqlUtil.BuildDelete(list.TableName, SqlUtil.BuildWhere(list.Pairs))); }
private static StringBuilder PrepareInsertBuilder(KeyValueListBase liste) { var pairs = liste.Pairs; var count = pairs.Count; var sb = new StringBuilder(150); sb.Append("INSERT INTO " + DatabaseUtil.Dialect.QuoteForTableName(liste.TableName) + " ("); for (var i = 0; i < count; i++) { var pair = pairs[i]; sb.Append(DatabaseUtil.Dialect.QuoteForColumnName(pair.Key)); if (i < count - 1) { sb.Append(","); } } sb.Append(") VALUES "); return sb; }
public void Insert(KeyValueListBase list) { ExecuteComand(SqlUtil.BuildInsert(list)); }