C# LINQ 判断记录重复
C# LINQ 判断记录重复
C# 全选
//表格数据源
var listSource = gvSummary.GetDataSource<dt_PaperType>();
//统计重复次数>1的记录
var list = (from s in listSource
.Where(w => !String.IsNullOrWhiteSpace(w.PaperName))
.GroupBy(g => g.PaperName)//需要判断是否重复的字段名称
select new
{
Key = s.Key,
RowCount = s.Count() //重复次数
} into w
where w.RowCount > 1
select w).ToList();
if (list.Count > 0)
{
Msg.Warning(list.FirstOrDefault().Key + " 纸质重复!");
return false;
}
版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
CSFramework.EF C/S框架网