代码逻辑如下:
//班级自动升级 //获取该学校还没有毕业的班级 List<ClassInfoes> classinfoeslist = classinfoesbll.GetList(SchoolCode).Where(a=>a.FlagGraduate==false).ToList(); List<int?> ListResult = new List<int?>(); foreach (var item in classinfoeslist) { ListResult.Add(item.EnterYear); } //升级的过程 最高年级显示毕业,其它的都升一个年级 if(entity.EnterYear>ListResult.Max()) { foreach (var item in classinfoeslist) { if (item.CurrentGrade == item.GraduateGrade) { item.FlagGraduate = true; } else { item.CurrentGrade = item.CurrentGrade + 1; var Grades = new Grades(); Grades = gradesbll.GetEntity(item.CurrentGrade); item.CurrentGradeName = Grades.Name; } } } IsOk = repositoryfactory.Repository().Insert(classinfoeslist);