I need to remove duplicate based on two column, if YY no column is duplicate but XX no column unique means I don’t want to delete, both column (YY no and XX no) duplicate than only remove duplicate , I couldn’t able to do so please help me anyone for this.
You can use this assign.
From row In yourDatatableVariable
Group row By
k1 = row(“XX no”).ToString.Trim,
k2 = row(“YY no”).ToString.Trim
Into grp = Group
in addition to Ömer we can do following:
(From d In dtData2.AsEnumerable
Group d By k1=d(0).toString.Trim, k2=d(2).toString.Trim Into grp=Group
Where grp.Count = 1
Select r = grp.First()).CopyToDataTable
Here we used the 2 cols for the grouping and fetching only the rows when group.count = 1
So we ommited 880, 88887779 - Kannan, Kala
But we do feel that your requirement is different. Maybe you can recheck with some other samples
Also have a look here (Non-LINQ, LINQ Approaches described)
This HowTo introduces on the different options for grouping data from a datatable in order to process the grouped data.
Grouping data and processing the grouped data is a common scenario e.g. when the grouped data is to aggregate like summing up, find maximum, get the average or concatening items.
Lets have a look on following data:
A possible scenario could be:
Create a report containing following information:
the region code
the sum of CaseCount per RegionCode
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.