c# dt.AsEnumerable ().Join用法


dt1.AsEnumerable().Join(dt2.AsEnumerable(), r1 => r1.Field<object>("id"), r2 => r2.Field<object>("id"), (r1, r2) => r1);

               //查找非小題非組合題,分數為空的序號
                List<int> nilScoreRow = detailTable.AsEnumerable().Where(x => LibSysUtils.ToDecimal(x["pre_score"]) == 0).
                    Where(x => LibSysUtils.ToBoolean(x["is_minor"]) == false).
                    Where(x => x.RowState != DataRowState.Deleted).
                    Where(x => LibSysUtils.ToInt(x["quiz_type"]) != (int)EnumERSType.CombinationType).
                    Select(x => LibSysUtils.ToInt(x["sort_no"])).ToList();
                //組合題
                EnumerableRowCollection<DataRow> combinationList = detailTable.AsEnumerable().
                    Where(x => LibSysUtils.ToInt(x["quiz_type"]) == (int)EnumERSType.CombinationType).
                    Where(x => x.RowState != DataRowState.Deleted);
                //查找有小題分數的組合題
                List<int> nilCombinationList = detailTable.AsEnumerable().Where(x => LibSysUtils.ToBoolean(x["is_minor"]) == true).
                    Where(x => LibSysUtils.ToDecimal(x["pre_score"]) == 0).
                    Where(x => x.RowState != DataRowState.Deleted).
                    Join(combinationList, x => x.Field<object>("parent_id"), y => y.Field<object>("quiz_id"), (x, y) => y)
                    .Select(y=> LibSysUtils.ToInt(y["sort_no"])).Distinct().ToList();
                nilScoreRow.AddRange(nilCombinationList);

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM