} // end method browseButton_Click // fill our titleBindingSource with all rows, ordered by title private void RefreshTitles() { // Dispose old DBContext, if any if (dbcontext != null) { dbcontext.Dispose(); } // create new DBContext so we can reorder records based on edits dbcontext = new BooksExamples.BooksEntities(); // use LINQ to order the Titles table contents by title dbcontext.Titles .OrderBy(book => book.Title1) .Load(); // specify DataSource for addressBindingSource titleBindingSource.DataSource = dbcontext.Titles.Local; titleBindingSource.MoveFirst(); // go to first result findTextBox.Clear(); // clear the Find TextBox } // end method RefreshTitles
// fill our authorBindingSource with all rows, ordered by name private void RefreshAuthors() { // Dispose old DBContext, if any if (dbcontext != null) { dbcontext.Dispose(); } // create new DBContext so we can reorder records based on edits dbcontext = new BooksExamples.BooksEntities(); // use LINQ to order the Authors table contents // by last name, then first name dbcontext.Authors .OrderBy(entry => entry.LastName) .ThenBy(entry => entry.FirstName) .Load(); // specify DataSource for addressBindingSource authorBindingSource.DataSource = dbcontext.Authors.Local; authorBindingSource.MoveFirst(); // go to first result findTextBox.Clear(); // clear the Find TextBox } // end method RefreshAuthors