//I have a class called tmpdata that looks like this
public class tmpdata
{
public tmpdata() { }
public tmpdata(int c1, int c2, int c3, int c4, int c5)
{
this.col1 = c1;
this.col2 = c2;
this.col3 = c3;
this.col4 = c4;
this.col5 = c5;
}
public int col1;
public int col2;
public int col3;
public int col4;
public int col5;
public string isDup;
}
//Data population into tmpdata List
List<tmpdata> data = new List<tmpdata>();
tmpdata d1 = new tmpdata(1, 2, 3, 4, 5); //Duplicate Record
tmpdata d2 = new tmpdata(1, 3, 4, 5, 6);
tmpdata d3 = new tmpdata(1, 2, 3, 4, 5); //Duplicate Record
tmpdata d4 = new tmpdata(4, 3, 2, 1, 5);
tmpdata d5 = new tmpdata(1, 5, 3, 4, 2);
tmpdata d6 = new tmpdata(2, 3, 4, 5, 1);
data.Add(d1);
data.Add(d2);
data.Add(d3);
data.Add(d4);
data.Add(d5);
data.Add(d6);
//Finding Duplicate rows with LINQ Query
var duplicateRows = from x in data
group x by new { x.col1, x.col2, x.col3, x.col4, x.col5 } into g
let ct = g.Count()
orderby ct
where ct > 1
select new tmpdata()
{
col1 = g.Key.col1,
col2 = g.Key.col2,
col3 = g.Key.col3,
col4 = g.Key.col4,
col5 = g.Key.col5,
};
//Now you can enumerate to Mark Duplicate records