public List <BotTemplateDropdownItem> getAll() { List <BotTemplateDropdownItem> temps = new List <BotTemplateDropdownItem>(); using (SqlConnection conn = new SqlConnection(this.ConnString)) { using (SqlCommand command = new SqlCommand()) { StringBuilder sqlCommand = new StringBuilder(); sqlCommand.Append("SELECT * FROM robottemplates"); command.CommandText = sqlCommand.ToString(); command.Connection = conn; conn.Open(); using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { BotTemplateDropdownItem tmp = new BotTemplateDropdownItem(); tmp.id = Convert.ToInt32(reader["id"]); tmp.name = Convert.ToString(reader["name"]); temps.Add(tmp); } } } } return(temps); }
public static string GetLookupStatement(BotTemplateDropdownItem template) { StringBuilder sb = new StringBuilder(); sb.AppendLine("DECLARE @templateID int"); sb.AppendLine("SET @templateID = (SELECT TOP 1 id from robottemplates WHERE [name] = '" + template.name + "' ORDER BY id DESC)"); return(sb.ToString()); }