DataTable通過Linq轉List
阿新 • • 發佈:2018-12-03
DataTable dt = dao.GetAnswerInfoByQuestionId(questionId); if (dt != null && dt.Rows.Count > 0) { var rowColl = dt.Rows; return (from DataRow row in rowColl select new DBEntityAnswerInfo { ID = CF.ToInt(row["ID"], -1), AnswerCode = CF.ToString(row["AnswerCode"]), AnswerContent = CF.ToString(row["AnswerContent"]), IsResult = CF.ToInt(row["IsResult"], -1) }).ToList(); }