Пример #1
0
        /// <summary>
        /// 学生を学校と関連付けてデータベースに挿入します。
        /// 学校が存在しない場合は新規に学校を登録します。
        /// </summary>
        /// <param name="student"></param>
        /// <param name="schoolName"></param>
        public Student InsertStudent(Student student, string schoolName)
        {
            if (this.HasSchool(schoolName) == false)
            {
                this.InsertSchool(new School() { Name = schoolName });
            }

            //IDの関連付け
            var school = this.GetSchool(schoolName);
            student.SchoolId = this.GetSchool(schoolName).Id;

            this.context.Student.InsertOnSubmit(student);
            this.SecureSubmitChanges();
            return student;
        }
Пример #2
0
 public Student InsertStudent(Student student)
 {
     this.context.Student.InsertOnSubmit(student);
     this.SecureSubmitChanges();
     return student;
 }
 partial void DeleteStudent(Student instance);
 partial void UpdateStudent(Student instance);
 partial void InsertStudent(Student instance);
Пример #6
0
        private void RegisterButtonClick(object sender, RoutedEventArgs e)
        {
            //入力のチェック
            if (this.CanRegister() == false)
            {
                return;
            }

            var student = new Student()
            {
                Name = this.textBoxStudentName.Text
            };
            student = sql.InsertStudent(student, this.textBoxSchoolName.Text);

            this.observableStudent.Add(student);
            this.ClearTextBox();
        }