I use the code below to get the duplicated rows for 3 columns: String, Date, Money. I wonder if there is any general method that I can input a dynamic List of column name in this LINQ to find duplicated rows?
DataTable allDuplicates = dt.AsEnumerable()
.GroupBy(dr => new
{
Field1 = dr.Field<object>("String"),
Field2 = dr.Field<object>("Date"),
Field3 = dr.Field<object>("Money"),
})
.Where(g => g.Count() > 1)
.SelectMany(g => g)
.ToList().CopyToDataTable();
}