using System; using System.Collections.Generic; using System.Text; using System.Data; using MySql.Data.MySqlClient; namespace CSVDownloader.Store { class ParkingCreditCardAgenciesSpotIDDAO : MySQL { public ParkingCreditCardAgenciesSpotIDDAO(MySqlConnection conn) : base(conn) { } public Dictionary GetDictionary(Code.CreditAgent agent) { var dic = new Dictionary(); String code = Code.CreditAgenciesMap.GetID(agent); var tbl = new DataTable(); String replace_id = "@id"; String sql = $"select CreditcardAgenciesSpotName, SpotID from parking_creditcard_agencies_spotid " + $"where CreditcardAgenciesID = {replace_id};"; using (var adpt = new MySqlDataAdapter(sql, conn_)) { adpt.SelectCommand.Parameters.AddWithValue(replace_id, code); adpt.SelectCommand.Prepare(); adpt.Fill(tbl); } foreach (DataRow row in tbl.Rows) { dic.Add(row[0].ToString(), row[1].ToString()); } return dic; } } }