public void InsertStudents() { University yale = dataContext.Universities.First(un => un.Name.Equals("Yale")); // the above is the same as below with the lambda(=>) expression //"from university in dataContext.University where university == "Yale" select university" University ist = dataContext.Universities.First(un => un.Name.Equals("IST")); List <Student> students = new List <Student>(); students.Add(new Student { Name = "Carla", Gender = "Female", UniversityId = yale.Id }); students.Add(new Student { Name = "Tonie", Gender = "Male", University = yale }); students.Add(new Student { Name = "Leyle", Gender = "Female", University = ist }); students.Add(new Student { Name = "Jame", Gender = "trans", University = ist }); dataContext.Students.InsertAllOnSubmit(students); dataContext.SubmitChanges(); MainDataGrid.ItemsSource = dataContext.Students; }
public void InsertUniversities() { dataContext.ExecuteCommand("delete from University"); University yale = new University(); yale.Name = "Yale"; University cambridge = new University(); cambridge.Name = "Cambridge"; dataContext.Universities.InsertOnSubmit(yale); dataContext.Universities.InsertOnSubmit(cambridge); dataContext.SubmitChanges(); MainDataGrid.ItemsSource = dataContext.Universities; }
public void InsertUniversities() { University harvard = new University(); harvard.Name = "Harvard"; dataContext.Universities.InsertOnSubmit(harvard); dataContext.SubmitChanges(); MainDataGrid.ItemsSource = dataContext.Universities; }
public void InsertUniversities() { 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 MIT = new University(); MIT.Name = "MIT"; dataContext.Universities.InsertOnSubmit(MIT); University yale = new University(); yale.Name = "yale"; dataContext.Universities.InsertOnSubmit(yale); dataContext.SubmitChanges(); MainDataGrid.ItemsSource = dataContext.Universities; }