public void Finish(string Table) { switch (this.CommandType) { case SqlCommandType.INSERT: { StringBuilder BuilderValuesA = new StringBuilder(); StringBuilder BuilderValuesB = new StringBuilder(); foreach (string Name in InsertValues.Keys) { BuilderValuesA.Append(Name).Append(", "); BuilderValuesB.Append("@").Append(Name).Append(", "); object Value; if (!InsertValues.TryGetValue(Name, out Value)) { throw new Exception("[INSERT] Failed to get value."); } Handler.AddParameter("@" + Name, Value); } BuilderValuesA.Length -= 2; BuilderValuesB.Length -= 2; Handler.SetCommand(string.Format(CommandString, Table, BuilderValuesA.ToString(), BuilderValuesB.ToString())); BuilderValuesA.Clear(); BuilderValuesB.Clear(); break; } case SqlCommandType.UPDATE: { StringBuilder BuilderValues = new StringBuilder(); foreach (string Name in UpdateValues.Keys) { BuilderValues.Append(Name).Append(" = @").Append(Name).Append(", "); object Value; if (!UpdateValues.TryGetValue(Name, out Value)) { throw new Exception("[UPDATE] Failed to get value."); } Handler.AddParameter("@" + Name, Value); } BuilderValues.Length -= 2; if (UseWhere) { StringBuilder BuilderWhereValues = new StringBuilder(); foreach (string Name in WhereValues.Keys) { BuilderWhereValues.Append(Name).Append(" = @").Append(Name).Append(" AND "); object Value; if (!WhereValues.TryGetValue(Name, out Value)) { throw new Exception("[UPDATE] Failed to get value."); } Handler.AddParameter("@" + Name, Value); } BuilderWhereValues.Length -= 5; Handler.SetCommand(string.Format(CommandString, Table, BuilderValues.ToString(), BuilderWhereValues.ToString())); BuilderValues.Clear(); BuilderWhereValues.Clear(); } else { Handler.SetCommand(string.Format(CommandString, Table, BuilderValues.ToString())); } break; } case SqlCommandType.SELECT: { if (UseWhere) { StringBuilder BuilderWhereValues = new StringBuilder(); foreach (string Name in WhereValues.Keys) { BuilderWhereValues.Append(Name).Append(" = @").Append(Name).Append(" AND "); object Value; if (!WhereValues.TryGetValue(Name, out Value)) { throw new Exception("[UPDATE] Failed to get value."); } Handler.AddParameter("@" + Name, Value); } BuilderWhereValues.Length -= 5; Handler.SetCommand(string.Format(CommandString, Table, BuilderWhereValues.ToString())); BuilderWhereValues.Clear(); } else { Handler.SetCommand(string.Format(CommandString, Table)); } break; } case SqlCommandType.DELETE: { if (UseWhere) { StringBuilder BuilderWhereValues = new StringBuilder(); foreach (string Name in WhereValues.Keys) { BuilderWhereValues.Append(Name).Append(" = @").Append(Name).Append(" AND "); object Value; if (!WhereValues.TryGetValue(Name, out Value)) { throw new Exception("[UPDATE] Failed to get value."); } Handler.AddParameter("@" + Name, Value); } BuilderWhereValues.Length -= 5; Handler.SetCommand(string.Format(CommandString, Table, BuilderWhereValues.ToString())); BuilderWhereValues.Clear(); } else { Handler.SetCommand(string.Format(CommandString, Table)); } break; } } }