void _bgWork_DoWork(object sender, DoWorkEventArgs e) { // 取得測驗資料 _AllQuizData = _UDTTransfer.GetAllQuizData(); // 取得所選學生測驗資料 _StudentQuizDataList = _UDTTransfer.GetStudQuizDataByStudentIDList(_SelectStudentIDList); _QuizIDDict.Clear(); // 比對測驗資料名稱 foreach (DAO.UDT_QuizDef QN in _AllQuizData) { int count = 0; int id = int.Parse(QN.UID); foreach (DAO.UDT_StudQuizDataDef StudQ in _StudentQuizDataList.Where(x => x.QuizID == id)) { count++; } // 有資料 if (count > 0) { if (!_QuizIDDict.ContainsKey(QN.QuizName)) { _QuizIDDict.Add(QN.QuizName, id); } } } }