static void Main(string[] args) { string connectionString = "metadata=res://*/ClassAdministrationDatabase.csdl|res://*/ClassAdministrationDatabase.ssdl|res://*/" + "ClassAdministrationDatabase.msl;provider=System.Data.SqlClient;provider connection string=\"Data Source=SZARNYASG-PC\\SQLEXPRESS;Initial Catalog=ClassAdministration;Integrated Security=True\""; EntityConnection ec = new EntityConnection(); ec.ConnectionString = connectionString; using (ClassAdministrationEntityContext context = new ClassAdministrationEntityContext(ec)) { Group group1 = new Group(); Room room1 = context.RoomSet.First(); Instructor instructor1 = context.InstructorSet.First(); Course course1 = context.CourseSet.First(); Semester semester = context.SemesterSet.First(); context.GroupSet.AddObject(group1); context.SaveChanges(); } }
public void UpdateInstructors(Instructor[] instructors) { using (ClassAdministrationEntityContext context = new ClassAdministrationEntityContext(BUTEClassAdministrationService.Properties.Resources.connectionString)) { foreach (var instructor in instructors) { context.InstructorSet.ApplyChanges(instructor); } context.SaveChanges(); } }
public void UpdateCourses(Course[] courses) { using (ClassAdministrationEntityContext context = new ClassAdministrationEntityContext(BUTEClassAdministrationService.Properties.Resources.connectionString)) { foreach (var course in courses) { context.CourseSet.ApplyChanges(course); } context.SaveChanges(); } }
public void CreateGroup(Group[] groups) { using (ClassAdministrationEntityContext context = new ClassAdministrationEntityContext(BUTEClassAdministrationService.Properties.Resources.connectionString)) { foreach (var group in groups) { context.GroupSet.ApplyChanges(group); } context.SaveChanges(); } }
public void UpdateStudents(Student[] students) { using (ClassAdministrationEntityContext context = new ClassAdministrationEntityContext(BUTEClassAdministrationService.Properties.Resources.connectionString)) { foreach (var student in students) { context.StudentSet.ApplyChanges(student); } context.SaveChanges(); } }
public void MoveStudent(int studentId, int courseId) { using (ClassAdministrationEntityContext context = new ClassAdministrationEntityContext(BUTEClassAdministrationService.Properties.Resources.connectionString)) { Student student = context.StudentSet.Where(s => s.Id == studentId).First(); Course course = context.CourseSet.Where(c => c.Id == courseId).First(); student.Course = course; context.StudentSet.ApplyChanges(student); context.SaveChanges(); } }
public void DeleteInstructors(int[] instructorIds) { using (ClassAdministrationEntityContext context = new ClassAdministrationEntityContext(BUTEClassAdministrationService.Properties.Resources.connectionString)) { var instructors = context.InstructorSet.Where(instructor => instructorIds.Contains(instructor.Id)); foreach (var instructor in instructors) { context.DeleteObject(instructor); } context.SaveChanges(); } }
public void DeleteStudents(int[] studentIds) { using (ClassAdministrationEntityContext context = new ClassAdministrationEntityContext(BUTEClassAdministrationService.Properties.Resources.connectionString)) { var students = context.StudentSet.Where(student => studentIds.Contains(student.Id)); foreach (var student in students) { context.DeleteObject(student); } context.SaveChanges(); } }
public void CreateStudents(Student[] students) { using (ClassAdministrationEntityContext context = new ClassAdministrationEntityContext(BUTEClassAdministrationService.Properties.Resources.connectionString)) { foreach (var student in students) { // skip duplicates if (context.StudentSet.Where(Student => Student.Neptun == student.Neptun).Any()) { continue; } ; context.StudentSet.ApplyChanges(student); } context.SaveChanges(); } }
public void DeleteGroups(int semesterId) { using (ClassAdministrationEntityContext context = new ClassAdministrationEntityContext(BUTEClassAdministrationService.Properties.Resources.connectionString)) { var groups = context.GroupSet.Where(group => group.Semester.Id == semesterId); foreach (var group in groups) { foreach (var student in group.Student) { student.Group = null; } } foreach (var group in groups) { foreach (var student in group.Student) { context.DeleteObject(group); } } context.SaveChanges(); } }