0

Need help with this lambda expression. My method is ineffective at eliminating duplicates from a record set.

private DataTable StripDuplicatesFromClientLeadTable(DataSet  dsLeadTrack)
{
    var dataTable = dsLeadTrack.Tables[0];
    if (dataTable.Rows.Count == 0) return dataTable;
    var result = dataTable.AsEnumerable()
        .GroupBy(x => x.Field<int>("ClientId"))
        .Select(g => g.First())
        .CopyToDataTable();
    return result;
}
Leonardo Wildt
  • 2,529
  • 5
  • 27
  • 56
  • Do you have sample input records and what you want the output to be ? – Habib Jul 09 '15 at 17:57
  • I have a data table that returns from a stored procedure. I added functionality to my application so that more views could see the data. In doing so i found that my data set included duplicate records into my data set. – Leonardo Wildt Jul 09 '15 at 18:00

0 Answers0