public void InsertStudent() { University yale = dataContext.Universities.First(un => un.Name.Equals("Yale")); University cambridge = dataContext.Universities.First(un => un.Name.Equals("Cambridge")); List <Student> students = new List <Student>(); students.Add(new Student { Name = "Peem", Gender = "male", UniversityId = cambridge.Id }); students.Add(new Student { Name = "Jame", Gender = "trans-gender", UniversityId = yale.Id }); students.Add(new Student { Name = "Judith", Gender = "female", University = cambridge }); dataContext.Students.InsertAllOnSubmit(students); dataContext.SubmitChanges(); MainDataGrid.ItemsSource = dataContext.Students; }
// 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; }
partial void DeleteUniversity(University instance);
partial void UpdateUniversity(University instance);
partial void InsertUniversity(University instance);