I’m working in an automation in C#. I have an excel file with data from invoices and users who have to approve it.
The DataTable contains this columns:
Number, Amount, Department, username.
For the same number, amount and department i have two or more different usernames.
For example:
Number, Amount, Department, username.
100, US$ 1424, XX, Rodrigo
100, US$ 1424, XX, John
I have to notify them that they need to approve the invoice.
I want to get a list where i can get this as result:
100, US$ 1424, XX, Rodrigo, John
(From row In dt.AsEnumerable()
Group row By key = New With {
Key .Number = row(“Number”),
Key .Amount = row(“Amount”),
Key .Department = row(“Department”)
} Into Group
Select resultTable.Rows.Add(key.Number, key.Amount, key.Department, String.Join(", ", Group.Select(Function(r) r(“username”).ToString())))).CopyToDataTable()
Make sure ResultTable has columns: Number, Amount, Department, Usernames.