Ejemplo n.º 1
0
        public IEnumerable <Specialty> GetCharacterSpecialties(Character character)
        {
            var specialties = new List <Specialty>();

            var systemdb = new TephraSystemDataAccessLayer();

            using (var con = new MySql.Data.MySqlClient.MySqlConnection(connectionString))
            {
                var cmd = new MySql.Data.MySqlClient.MySqlCommand(
                    "SELECT ID, CharacterID, Ch.SpecialtyID " +
                    "FROM CharactersSpecialty AS Ch JOIN Specialties AS Sp ON Sp.SpecialtyID = Ch.SpecialtyID " +
                    "WHERE CharacterID = @CharacterID ORDER BY ID"
                    , con
                    );
                cmd.Parameters.AddWithValue("@CharacterID", character.ID);

                con.Open();
                var rdrCharacter = cmd.ExecuteReader();
                while (rdrCharacter.Read())
                {
                    var specialtyID = rdrCharacter.GetInt32("SpecialtyID");
                    var specialty   = systemdb.GetSpecialty(specialtyID);
                    specialty.ID          = rdrCharacter.GetInt32("ID");
                    specialty.CharacterID = rdrCharacter.GetInt32("CharacterID");
                    specialties.Add(specialty);
                }
                con.Close();
            }
            return(specialties);
        }