public void AddStudentForLesson(string number, int id) { var studentLesson = new StudentLesson { LessonId = id, StudentId = _studentRepository.Get(x => x.SchoolNumber == number).Id }; _dbContext.StudentLessons.Add(studentLesson); _dbContext.SaveChanges(); }
public int SaveChanges() { try { // Transaction işlemleri burada ele alınabilir veya Identity Map kurumsal tasarım kalıbı kullanılarak // sadece değişen alanları güncellemeyide sağlayabiliriz. return(_dbContext.SaveChanges()); } catch { // Burada DbEntityValidationException hatalarını handle edebiliriz. throw; } }