I am new RPA developer. I am stuck with one use case where i need to fetch 2 columns from a datatable:
Here is the example:
I have 3 columns: SF-Case, Item And Status(Only Item column has unique id’s)
I need to get distinct SF-case
For each SF-case, i need to find it’s corresponding Item and Status
So far i am able to get distinct SF-case values and Item by using below ling queries:
Using in assign activity,
dt1.AsEnumerable.Select(Function(r) r(“SF-Case”).ToString).ToArray.Distinct
Again using assign activity:
Using for each loop for sfca aaray store from above query, (Where sfca is for each loop item)
dt1.AsEnumerable.Where(Function(r) r(“SF-Case”).ToString = sfca).Select(Function(r) r(“Item”).ToString).ToArray
Issue: is i need both item and staus for each SFCA in a single linq query, how can we do that?
(From d In File_Table.AsEnumerable
Group d By k=d(“SF-Case”).toString.Trim Into grp=Group
Let n = String.Join(“,”,grp.Select(Function (x) x(“Item”).toString.Trim).toArray)
Let p = String.Join(“,”,grp.Select(Function (x) x(“Status”).toString.Trim).toArray)
Let ra = New Object(){k,n,p}
Select dtreport.Rows.Add(ra)).CopyToDataTable
Thanks for the LINQ query. It’s working.
Apologies, slight change in output requirement:
I need List of items with Status ‘Success’ and 'Fail Separately on the basis on SF-case
(From d In File_Table.AsEnumerable
Group d By k=d(“SF-Case”).toString.Trim, k1=d(“Status”).toString.Trim Into grp=Group
Let n = String.Join(“,”,grp.Select(Function (x) x(“Item”).toString.Trim).toArray)
Let ra = New Object(){k,n,k1}
Select dtreport.Rows.Add(ra)).CopyToDataTable