Social Icons

Wednesday, January 25, 2012

Finding Duplicate Rows in DataTable using Linq

var duplicates = dt.AsEnumerable()
                .GroupBy(r => new { a = r[0], b = r[1] })
                .Where(gr => gr.Count() > 1);
lbMsg.Text = "Duplicate Record found for Rows: " + String.Join(", ", duplicates.Select(dupl => dupl.Key));


//End

1 comment:

  1. update duplicate rows in data table......Send me pghante@gmail.com

    ReplyDelete

 

Sample text

Sample Text