I want to remove duplicates from datatable using Linq queries

In output file i have 2 columns Ticket Number and Status i want to check the data in both the columns if i found both columns have same value( duplicates) bot has to remove first row and last row should be their how to do it

please help me with the logic
Thanks

Hi @vinjam_likitha

dtOutput = (From row In dtTickets.AsEnumerable()
            Group row By TicketNumber = row("Ticket Number").ToString(), Status = row("Status").ToString() Into Group
            Select Group.Last()).CopyToDataTable()

Regards,

@vinjam_likitha

outputDataTable = outputDataTable.AsEnumerable().
                   GroupBy(Function(row) New With { Key .TicketNumber = row("Ticket Number").ToString(), Key .Status = row("Status").ToString()}).
                   Select(Function(group) group.Last()).
                   CopyToDataTable()

Just use the Remove Duplicate Rows activity.

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