Ejemplo n.º 1
0
        static public List <K12.Data.StudentRecord> K12Data_StudentRecord(List <K12.Data.StudentRecord> StudentList)
        {
            //整理出學生&班級資料清單
            List <string> classIDList = new List <string>();

            foreach (K12.Data.StudentRecord student in StudentList)
            {
                if (!string.IsNullOrEmpty(student.RefClassID))
                {
                    if (!classIDList.Contains(student.RefClassID))
                    {
                        classIDList.Add(student.RefClassID);
                    }
                }
            }
            //一次取得班級清單
            List <K12.Data.ClassRecord> classList = K12.Data.Class.SelectByIDs(classIDList);
            //班級ID對照清單
            Dictionary <string, K12.Data.ClassRecord> classDic = new Dictionary <string, K12.Data.ClassRecord>();

            foreach (K12.Data.ClassRecord classRecord in classList)
            {
                if (!classDic.ContainsKey(classRecord.ID))
                {
                    classDic.Add(classRecord.ID, classRecord);
                }
            }

            List <StudentSortObj_K12Data> list = new List <StudentSortObj_K12Data>();

            foreach (K12.Data.StudentRecord student in StudentList)
            {
                if (!string.IsNullOrEmpty(student.RefClassID))
                {
                    StudentSortObj_K12Data obj = new StudentSortObj_K12Data(classDic[student.RefClassID], student);
                    list.Add(obj);
                }
                else
                {
                    StudentSortObj_K12Data obj = new StudentSortObj_K12Data(null, student);
                    list.Add(obj);
                }
            }
            list.Sort(SortK12Data_StudentRecord);

            return(list.Select(x => x._StudentRecord).ToList());
        }
Ejemplo n.º 2
0
 static private int SortK12Data_StudentRecord(StudentSortObj_K12Data obj1, StudentSortObj_K12Data obj2)
 {
     return(obj1._SortString.CompareTo(obj2._SortString));
 }