IQueryable<IGrouping<TKey, TSource>>转换为List<Entity>()

       var tempList = ctx.V_Record.Where(p => p.SpecificType.Equals(specificType) || specificType.Equals("0")).OrderByDescending(p => p.DrawingId).ThenByDescending(p => p.Id).GroupBy(p => p.DrawingId).OrderByDescending(p => p.Key);            
       Dictionary<string, string> dic = new Dictionary<string, string>();       

       //先循环IGroupingTKey
       foreach
(IGrouping<int, V_Record> iGrouping in tempList) {           //再循环IGroupingTSource
foreach (V_Record v_record in iGrouping) { var tempDrawingNo = v_record.DrawingNum; if (string.IsNullOrEmpty(tempDrawingNo)) { editionList.Add(v_record); } else if (!dic.Keys.Contains(tempDrawingNo)) { editionList.Add(v_record); } if (!string.IsNullOrEmpty(tempDrawingNo) && !dic.Keys.Contains(tempDrawingNo)) { dic.Add(tempDrawingNo, tempDrawingNo); } } }

 

posted @ 2012-06-01 16:39  沈阳毛毛  阅读(1750)  评论(0编辑  收藏  举报