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);
           }
原文地址:https://www.cnblogs.com/dashi/p/3680503.html