public void InsertUniversites() { dataContext.ExecuteCommand("Delete from University"); University yale = new University(); yale.Name = "Yale"; dataContext.Universities.InsertOnSubmit(yale); University beijingTech = new University(); beijingTech.Name = "Beijing Tech"; dataContext.Universities.InsertOnSubmit(beijingTech); dataContext.SubmitChanges(); MainDataGrid.ItemsSource = dataContext.Universities; }
public void InsertUniversities() { dataContext.ExecuteCommand("delete from University"); University yale = new University(); yale.Name = "Yale University"; dataContext.Universities.InsertOnSubmit(yale); University illinoisStateUniversity = new University(); illinoisStateUniversity.Name = "Illinois State University"; dataContext.Universities.InsertOnSubmit(illinoisStateUniversity); dataContext.SubmitChanges(); MainDataGrid.ItemsSource = dataContext.Universities; }
// insert universities into database public void InsertUniversities() { // delete all entries dataContext.ExecuteCommand("delete from University"); University yale = new University(); University mizzou = new University(); yale.Name = "Yale"; mizzou.Name = "Mizzou"; // prepare data to be submitted to database dataContext.Universities.InsertOnSubmit(yale); dataContext.Universities.InsertOnSubmit(mizzou); // submit dataContext.SubmitChanges(); // display data in the MainDataGrid MainDataGrid.ItemsSource = dataContext.Universities; }