当前位置: 首页>>代码示例>>C#>>正文


C# ScheduleContext.SaveChanges方法代码示例

本文整理汇总了C#中Schedule.DataLayer.ScheduleContext.SaveChanges方法的典型用法代码示例。如果您正苦于以下问题:C# ScheduleContext.SaveChanges方法的具体用法?C# ScheduleContext.SaveChanges怎么用?C# ScheduleContext.SaveChanges使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Schedule.DataLayer.ScheduleContext的用法示例。


在下文中一共展示了ScheduleContext.SaveChanges方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddConfigOption

        public ConfigOption AddConfigOption(ConfigOption co)
        {
            using (var context = new ScheduleContext(ConnectionString))
            {
                context.Config.Add(co);
                context.SaveChanges();

                return co;
            }
        }
开发者ID:BesuglovS,项目名称:ScheduleRepository,代码行数:10,代码来源:ScheduleRepository.cs

示例2: AddTeacher

        public Teacher AddTeacher(Teacher teacher)
        {
            using (var context = new ScheduleContext(ConnectionString))
            {
                teacher.TeacherId = 0;

                context.Teachers.Add(teacher);
                context.SaveChanges();

                return teacher;
            }
        }
开发者ID:BesuglovS,项目名称:ScheduleRepository,代码行数:12,代码来源:ScheduleRepository.cs

示例3: AddTeacherForDisciplineRange

        public void AddTeacherForDisciplineRange(IEnumerable<TeacherForDiscipline> teacherForDisciplineList)
        {
            using (var context = new ScheduleContext(ConnectionString))
            {
                foreach (var teacherForDiscipline in teacherForDisciplineList)
                {
                    teacherForDiscipline.TeacherForDisciplineId = 0;
                    context.TeacherForDiscipline.Add(teacherForDiscipline);
                }

                context.SaveChanges();
            }
        }
开发者ID:BesuglovS,项目名称:ScheduleRepository,代码行数:13,代码来源:ScheduleRepository.cs

示例4: AddStudentGroup

        public StudentGroup AddStudentGroup(StudentGroup studentGroup)
        {
            using (var context = new ScheduleContext(ConnectionString))
            {
                studentGroup.StudentGroupId = 0;

                context.StudentGroups.Add(studentGroup);
                context.SaveChanges();

                return studentGroup;
            }
        }
开发者ID:BesuglovS,项目名称:ScheduleRepository,代码行数:12,代码来源:ScheduleRepository.cs

示例5: AddStudentsInGroups

        public StudentsInGroups AddStudentsInGroups(StudentsInGroups studentsInGroups)
        {
            using (var context = new ScheduleContext(ConnectionString))
            {
                studentsInGroups.StudentsInGroupsId = 0;

                studentsInGroups.Student = context.Students.FirstOrDefault(s => s.StudentId == studentsInGroups.Student.StudentId);
                studentsInGroups.StudentGroup = context.StudentGroups.FirstOrDefault(sg => sg.StudentGroupId == studentsInGroups.StudentGroup.StudentGroupId);

                context.StudentsInGroups.Add(studentsInGroups);
                context.SaveChanges();

                return studentsInGroups;
            }
        }
开发者ID:BesuglovS,项目名称:ScheduleRepository,代码行数:15,代码来源:ScheduleRepository.cs

示例6: AddRingRange

        public void AddRingRange(IEnumerable<Ring> ringList)
        {
            using (var context = new ScheduleContext(ConnectionString))
            {
                foreach (var ring in ringList)
                {
                    ring.RingId = 0;
                    context.Rings.Add(ring);
                }

                context.SaveChanges();
            }
        }
开发者ID:BesuglovS,项目名称:ScheduleRepository,代码行数:13,代码来源:ScheduleRepository.cs

示例7: AddScheduleNoteRange

        public void AddScheduleNoteRange(IEnumerable<ScheduleNote> scheduleNoteList)
        {
            using (var context = new ScheduleContext(ConnectionString))
            {
                foreach (var sNote in scheduleNoteList)
                {
                    sNote.ScheduleNoteId = 0;

                    context.ScheduleNotes.Add(sNote);
                }

                context.SaveChanges();
            }
        }
开发者ID:BesuglovS,项目名称:ScheduleRepository,代码行数:14,代码来源:ScheduleRepository.cs

示例8: AddFaculty

        public Faculty AddFaculty(Faculty faculty)
        {
            using (var context = new ScheduleContext(ConnectionString))
            {
                faculty.FacultyId = 0;

                context.Faculties.Add(faculty);
                context.SaveChanges();

                return faculty;
            }
        }
开发者ID:BesuglovS,项目名称:ScheduleRepository,代码行数:12,代码来源:ScheduleRepository.cs

示例9: AddFacultyRange

        public void AddFacultyRange(IEnumerable<Faculty> facultyList)
        {
            using (var context = new ScheduleContext(ConnectionString))
            {
                foreach (var faculty in facultyList)
                {
                    faculty.FacultyId = 0;
                    context.Faculties.Add(faculty);
                }

                context.SaveChanges();
            }
        }
开发者ID:BesuglovS,项目名称:ScheduleRepository,代码行数:13,代码来源:ScheduleRepository.cs

示例10: AddExam

        public Exam AddExam(Exam exam)
        {
            using (var context = new ScheduleContext(ConnectionString))
            {
                exam.ExamId = 0;

                context.Exams.Add(exam);
                context.SaveChanges();

                return exam;
            }
        }
开发者ID:BesuglovS,项目名称:ScheduleRepository,代码行数:12,代码来源:ScheduleRepository.cs

示例11: AddExamsRange

        public void AddExamsRange(IEnumerable<Exam> examList)
        {
            using (var context = new ScheduleContext(ConnectionString))
            {
                foreach (var exam in examList)
                {
                    exam.ExamId = 0;
                    context.Exams.Add(exam);
                }

                context.SaveChanges();
            }
        }
开发者ID:BesuglovS,项目名称:ScheduleRepository,代码行数:13,代码来源:ScheduleRepository.cs

示例12: AddDisciplineRange

        public void AddDisciplineRange(IEnumerable<Discipline> disciplineList)
        {
            using (var context = new ScheduleContext(ConnectionString))
            {
                foreach (var discipline in disciplineList)
                {
                    var disciplineGroup = context.StudentGroups.FirstOrDefault(sg => sg.StudentGroupId == discipline.StudentGroup.StudentGroupId);
                    discipline.StudentGroup = disciplineGroup;
                    context.Disciplines.Add(discipline);
                }

                context.SaveChanges();
            }
        }
开发者ID:BesuglovS,项目名称:ScheduleRepository,代码行数:14,代码来源:ScheduleRepository.cs

示例13: AddDiscipline

        public Discipline AddDiscipline(Discipline discipline)
        {
            using (var context = new ScheduleContext(ConnectionString))
            {
                discipline.StudentGroup = context.StudentGroups.FirstOrDefault(sg => sg.StudentGroupId == discipline.StudentGroup.StudentGroupId);
                context.Disciplines.Add(discipline);

                context.SaveChanges();

                return discipline;
            }
        }
开发者ID:BesuglovS,项目名称:ScheduleRepository,代码行数:12,代码来源:ScheduleRepository.cs

示例14: AddConfigOptionRange

        public void AddConfigOptionRange(IEnumerable<ConfigOption> coList)
        {
            using (var context = new ScheduleContext(ConnectionString))
            {
                foreach (var co in coList)
                {
                    co.ConfigOptionId = 0;
                    context.Config.Add(co);
                }

                context.SaveChanges();
            }
        }
开发者ID:BesuglovS,项目名称:ScheduleRepository,代码行数:13,代码来源:ScheduleRepository.cs

示例15: AddLogEvent

        public LogEvent AddLogEvent(LogEvent logEvent)
        {
            using (var context = new ScheduleContext(ConnectionString))
            {
                logEvent.OldExam = context.Exams.FirstOrDefault(e => e.ExamId == logEvent.OldExam.ExamId);
                logEvent.NewExam = context.Exams.FirstOrDefault(e => e.ExamId == logEvent.NewExam.ExamId);

                context.EventLog.Add(logEvent);
                context.SaveChanges();

                return logEvent;
            }
        }
开发者ID:BesuglovS,项目名称:ScheduleRepository,代码行数:13,代码来源:ScheduleRepository.cs


注:本文中的Schedule.DataLayer.ScheduleContext.SaveChanges方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。