public List <Book> GetBooks() { MySqlConnection conn = DB.Connection(); conn.Open(); MySqlCommand cmd = conn.CreateCommand() as MySqlCommand; cmd.CommandText = @"SELECT books.* FROM patrons JOIN patrons_books ON (patrons.id = patrons_books.patron_id) JOIN books ON (patrons_books.book_id = books.id) WHERE patrons.id = @PatronId;"; cmd.Parameters.AddWithValue("@PatronId", this._id); MySqlDataReader rdr = cmd.ExecuteReader() as MySqlDataReader; List <Book> books = new List <Book> { }; while (rdr.Read()) { int bookId = rdr.GetInt32(0); Book newBook = Book.FindById(bookId); books.Add(newBook); } conn.Close(); if (conn != null) { conn.Dispose(); } return(books); }