使用Linq 做数据去重

 #region 数据去重复

                var reslut = new List<string>(); 需要去重的数据集合
                if (!string.IsNullOrEmpty(query.First().MergeOrders))//满足去重条件
                {
                    List<string> oldRecordList = GetOldDT(iQueryId);//去重的对比数据

                    //Linq  的 Except  方法去重                 

                    reslut = (from a in newUserRecordList
                              select a).Except
                          (from b in oldRecordList
                           select b).ToList();
                }
             reslut = reslut.Take(数量).ToList();//获取需要的数量
                #endregion
               

posted @ 2012-03-01 22:34  编程笔记  阅读(5600)  评论(0编辑  收藏  举报