Case is about detecting duplicates based on 1 column and deduplication by taking the last group member. When UnitCost occurs only 1 time, then also keeps it?
Assign Activity:
dtFiltered =
(From d in dtData.AsEnumerable
Group d by k=d("UnitCost").toString.ToUpper.Trim into grp=Group
Select g = grp.Last()).CopyToDataTable
When case is as described above but unique UnitCosts rows are also to get blocked, then we can do:
Assign Activity:
dtFiltered =
(From d In dtData.AsEnumerable
Group d By k=d("UnitCost").toString.ToUpper.Trim Into grp=Group
Where grp.Count > 1
Select g = grp.Last()).CopyToDataTable
When the first group members are to keep the we just use first() instead of last()
Select g = grp.First()).CopyToDataTable