Thursday, 27 June 2013

Getting Distinct Records from datatable and dataset

Following single line of code will avoid the duplicate rows of a DataTable:
dataTable.DefaultView.ToTable(true, "employeeid");
Where:
  • first parameter in ToTable() is a boolean which indicates whether you want distinct rows or not.
  • second option in the ToTable() is the column name based on which we have to select distinct rows.
The same can be done from a DataSet, by accessing a specific DataTable:
dataSet.Tables["Employee"].DefaultView.ToTable(t

No comments:

Post a Comment