public List <Specialty> GetSpecialtys() { MySqlConnection conn = DB.Connection(); conn.Open(); MySqlCommand cmd = conn.CreateCommand() as MySqlCommand; cmd.CommandText = @"SELECT specialties.* FROM doctors JOIN doctors_specialties ON (doctors.id = doctors_specialties.doctor_id) JOIN specialties ON (doctors_specialties.specialty_id = specialties.id) WHERE doctors.id = @DoctorId;"; MySqlParameter doctorIdParameter = new MySqlParameter(); doctorIdParameter.ParameterName = "@DoctorId"; doctorIdParameter.Value = _id; cmd.Parameters.Add(doctorIdParameter); MySqlDataReader rdr = cmd.ExecuteReader() as MySqlDataReader; List <Specialty> specialties = new List <Specialty> { }; while (rdr.Read()) { int specialtyId = rdr.GetInt32(0); string specialtyDescription = rdr.GetString(1); Specialty newSpecialty = new Specialty(specialtyDescription, specialtyId); specialties.Add(newSpecialty); } conn.Close(); if (conn != null) { conn.Dispose(); } return(specialties); }