Selection of Datatable Rows

Hi Guys

I want to remove the duplicates comparing both the Column 1 and Column 2. After removal of duplicates I want to have all three columns.

I tried DefaultView but it gets rid of the third column, which is needed for later processing.

Pls help !!!

I have a datatable with value as below -

[Column1,Column2,Column3

91125000000,5,13213

91125100000,5,13213

91125200000,5,13213

91125300000,5,13213

91125000000,5,13241

91125100000,5,13241

91125200000,5,13241

91125300000,5,13241

91125000000,4,53454

91125100000,4,53454

91125200000,4,53454

91125300000,4,53454

91125000000,4,53421

91125100000,4,53421

91125200000,4,53421

91125300000,4,53421

94532000000,5,1321

94532100000,5,1321

94532200000,5,1321

94532300000,5,1321

94532000000,5,43352

94532100000,5,43352

94532200000,5,43352

94532300000,5,43352

94532000000,4,1321

94532100000,4,1321

94532200000,4,1321

94532300000,4,1321

94532000000,4,1

94532100000,4,1

94532200000,4,1

94532300000,4,1

]

For distincting (taking first occurence of groups):

Assign Activity:
dtCleansed =

(From d in dtData.AsEnumerable
Group d by k1=d(0).toString.Trim, k2=d(1).toString.Trim into grp=Group
Select r=grp.First()).CopyToDataTable

For removing all duplicates:
Assign Activity:
dtCleansed =

(From d in dtData.AsEnumerable
Group d by k1=d(0).toString.Trim, k2=d(1).toString.Trim into grp=Group
Where grp.Count = 1
Select r=grp.First()).CopyToDataTable

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.