Linq使用GroupBy筛选数据

     StringBuilder sb = new StringBuilder();      

     List<IGrouping<string, modle>> listRepeat = modelList.GroupBy(l => l.IDCode).Where(g => g.Count() > 1).ToList();
           if (listRepeat.Count() > 0)
           {
               foreach (IGrouping<string, modle> data in listRepeat)
                   sb.AppendFormat("您输入了相同的身份证号/组织机构代码\\\"{0}\\\"!\\r\\n", data.Key);
           }

 

posted @ 2014-04-22 14:39  顿金  阅读(462)  评论(0编辑  收藏  举报