首页 > 技术文章 > Linq使用GroupBy筛选数据

dashi 2014-04-22 14:39 原文

     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);
           }

 

推荐阅读