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


C# DataLayer.ScheduleContext类代码示例

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


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

示例1: AddGroupsInFaculty

        public GroupsInFaculty AddGroupsInFaculty(GroupsInFaculty groupsInFaculty)
        {
            using (var context = new ScheduleContext(ConnectionString))
            {
                groupsInFaculty.GroupsInFacultyId = 0;

                groupsInFaculty.StudentGroup = context.StudentGroups.FirstOrDefault(gif => gif.StudentGroupId == groupsInFaculty.StudentGroup.StudentGroupId);
                groupsInFaculty.Faculty = context.Faculties.FirstOrDefault(gif => gif.FacultyId == groupsInFaculty.Faculty.FacultyId);

                context.GroupsInFaculties.Add(groupsInFaculty);
                context.SaveChanges();

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

示例2: FindConfigOption

 public ConfigOption FindConfigOption(string key)
 {
     using (var context = new ScheduleContext(ConnectionString))
     {
         return context.Config.FirstOrDefault(op => op.Key == key);
     }
 }
开发者ID:BesuglovS,项目名称:ScheduleRepository,代码行数:7,代码来源:ScheduleRepository.cs

示例3: FindFaculty

 public Faculty FindFaculty(string name)
 {
     using (var context = new ScheduleContext(ConnectionString))
     {
         return context.Faculties.FirstOrDefault(f => f.Name == name);
     }
 }
开发者ID:BesuglovS,项目名称:ScheduleRepository,代码行数:7,代码来源:ScheduleRepository.cs

示例4: ClearAllExams

        public void ClearAllExams()
        {
            using (var context = new ScheduleContext(ConnectionString))
            {
                var examIds = context.Exams.Select(e => e.ExamId).ToList();

                foreach (var examId in examIds)
                {
                    RemoveExam(examId);
                }
            }
        }
开发者ID:BesuglovS,项目名称:ScheduleRepository,代码行数:12,代码来源:ScheduleRepository.cs

示例5: FindAuditorium

 public Auditorium FindAuditorium(string name)
 {
     using (var context = new ScheduleContext(ConnectionString))
     {
         return context.Auditoriums.FirstOrDefault(a => a.Name == name);
     }
 }
开发者ID:BesuglovS,项目名称:ScheduleRepository,代码行数:7,代码来源:ScheduleRepository.cs

示例6: 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

示例7: 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

示例8: AddLessonWOLog

        public Lesson AddLessonWOLog(Lesson lesson)
        {
            using (var context = new ScheduleContext(ConnectionString))
            {
                lesson.LessonId = 0;

                lesson.TeacherForDiscipline = context.TeacherForDiscipline.FirstOrDefault(tfd => tfd.TeacherForDisciplineId == lesson.TeacherForDiscipline.TeacherForDisciplineId);
                lesson.Calendar = context.Calendars.FirstOrDefault(c => c.CalendarId == lesson.Calendar.CalendarId);
                lesson.Ring = context.Rings.FirstOrDefault(r => r.RingId == lesson.Ring.RingId);
                lesson.Auditorium = context.Auditoriums.FirstOrDefault(a => a.AuditoriumId == lesson.Auditorium.AuditoriumId);

                context.Lessons.Add(lesson);

                context.SaveChanges();

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

示例9: 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

示例10: AddLessonLogEventRange

        public void AddLessonLogEventRange(IEnumerable<LessonLogEvent> lessonLogEventList)
        {
            using (var context = new ScheduleContext(ConnectionString))
            {
                foreach (var lessonLogEvent in lessonLogEventList)
                {
                    lessonLogEvent.LessonLogEventId = 0;

                    lessonLogEvent.OldLesson = context.Lessons.FirstOrDefault(l => l.LessonId == lessonLogEvent.OldLesson.LessonId);
                    lessonLogEvent.NewLesson = context.Lessons.FirstOrDefault(l => l.LessonId == lessonLogEvent.NewLesson.LessonId);

                    context.LessonLog.Add(lessonLogEvent);
                }

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

示例11: AddLessonRange

        public void AddLessonRange(IEnumerable<Lesson> lessonList)
        {
            using (var context = new ScheduleContext(ConnectionString))
            {
                foreach (var lesson in lessonList)
                {
                    lesson.LessonId = 0;

                    lesson.TeacherForDiscipline = context.TeacherForDiscipline.FirstOrDefault(tfd => tfd.TeacherForDisciplineId == lesson.TeacherForDiscipline.TeacherForDisciplineId);
                    lesson.Calendar = context.Calendars.FirstOrDefault(c => c.CalendarId == lesson.Calendar.CalendarId);
                    lesson.Ring = context.Rings.FirstOrDefault(r => r.RingId == lesson.Ring.RingId);
                    lesson.Auditorium = context.Auditoriums.FirstOrDefault(a => a.AuditoriumId == lesson.Auditorium.AuditoriumId);

                    context.Lessons.Add(lesson);
                }

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

示例12: AddLessonLogEvent

        public LessonLogEvent AddLessonLogEvent(LessonLogEvent lessonLogEvent)
        {
            using (var context = new ScheduleContext(ConnectionString))
            {
                lessonLogEvent.LessonLogEventId = 0;
                lessonLogEvent.OldLesson = (lessonLogEvent.OldLesson == null) ? null : context.Lessons.FirstOrDefault(l => l.LessonId == lessonLogEvent.OldLesson.LessonId);
                lessonLogEvent.NewLesson = (lessonLogEvent.NewLesson == null) ? null : context.Lessons.FirstOrDefault(l => l.LessonId == lessonLogEvent.NewLesson.LessonId);

                context.LessonLog.Add(lessonLogEvent);
                context.SaveChanges();

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

示例13: AddLesson

        public Lesson AddLesson(Lesson lesson, string publicComment = "", string hiddenComment = "")
        {
            using (var context = new ScheduleContext(ConnectionString))
            {
                lesson.LessonId = 0;

                lesson.TeacherForDiscipline = context.TeacherForDiscipline.FirstOrDefault(tfd => tfd.TeacherForDisciplineId == lesson.TeacherForDiscipline.TeacherForDisciplineId);
                lesson.Calendar = context.Calendars.FirstOrDefault(c => c.CalendarId == lesson.Calendar.CalendarId);
                lesson.Ring = context.Rings.FirstOrDefault(r => r.RingId == lesson.Ring.RingId);
                lesson.Auditorium = context.Auditoriums.FirstOrDefault(a => a.AuditoriumId == lesson.Auditorium.AuditoriumId);

                context.Lessons.Add(lesson);

                context.LessonLog.Add(
                    new LessonLogEvent
                    {
                        OldLesson = null,
                        NewLesson = lesson,
                        DateTime = DateTime.Now,
                        PublicComment = publicComment,
                        HiddenComment = hiddenComment
                    }
                );
                context.SaveChanges();

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

示例14: AddGroupsInFacultyRange

        public void AddGroupsInFacultyRange(IEnumerable<GroupsInFaculty> groupsInFacultiesList)
        {
            using (var context = new ScheduleContext(ConnectionString))
            {
                foreach (var groupsInFaculty in groupsInFacultiesList)
                {
                    groupsInFaculty.GroupsInFacultyId = 0;

                    groupsInFaculty.StudentGroup = context.StudentGroups.FirstOrDefault(gif => gif.StudentGroupId == groupsInFaculty.StudentGroup.StudentGroupId);
                    groupsInFaculty.Faculty = context.Faculties.FirstOrDefault(gif => gif.FacultyId == groupsInFaculty.Faculty.FacultyId);

                    context.GroupsInFaculties.Remove(groupsInFaculty);
                }

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

示例15: 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


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