private string constructParamValues(DbParams valueParams) { var query = "("; foreach (var pair in valueParams.get()) { query += "@" + pair.ID + ", "; } return(query.Substring(0, query.Length - 2) + ")"); }
private object constructParamQuery(DbParams valueParams) { var query = ""; foreach (var pair in valueParams.get()) { if (pair.Name == "id") { continue; } query += pair.Name + "=@" + pair.ID + ", "; } return(query.Substring(0, query.Length - 2)); }
protected SqlCommand constructCommand(string query, DbParams valueParams) { var command = new SqlCommand { Connection = DbConnector.getConnection(), CommandText = query }; foreach (var pair in valueParams.get()) { if (pair.Value == null) { continue; } command.Parameters.AddWithValue(pair.ID, pair.Type); command.Parameters[pair.ID].Value = pair.Value; } return(command); }
protected object constructSearchParams(DbParams searchParams) { if (searchParams.count() == 0) { return(""); } var query = " WHERE "; var index = 0; foreach (var pair in searchParams.get()) { if (index++ != 0) { query += pair.BooleanOpr + " "; } query += pair.Name + " " + pair.Operator + " "; query += isStringType(pair.Type) ? "'" + pair.Value + "' " : pair.Value + " "; } return(query.Substring(0, query.Length - 1)); }