private void button_Click(object sender, RoutedEventArgs e) { string nameText = this.textBox1.Text; string schoolText = this.textBox.Text; // school変数に学校名を設定 School school = new School(); school.Name = schoolText; // データベースにschoolを登録 this.context.School.InsertOnSubmit(school); this.context.SubmitChanges(); // student変数に氏名を設定 Student student = new Student(); student.Name = nameText; student.SchoolId = school.Id; // データベースにstudentを登録 this.context.Student.InsertOnSubmit(student); this.context.SubmitChanges(); // 画面表示用コレクションにschoolを登録 this.observableStudent.Add(student); this.dataGrid.ItemsSource = this.observableStudent; }
partial void DeleteSchool(School instance);
partial void UpdateSchool(School instance);
partial void InsertSchool(School instance);