Fastest way to get value from one datatable without looping

Hi all, good day. i have an example 2 data table.
dtTableReport - let say there are 300,000 record on it.
dtTableReport

dtTableAvClass - this table is for lookup
dtTableAvClass

i would like to lookup the Classification from dtTableAvClass using ClassId in dtTableReport. how can i do this without using for each activity. this activity takes sometime to do it specially the record in dtTableReport is more than 300k. thank you.

Sample Result:
dtTableResult

Hi @arthurang ,
Have you try LinQ

(From row1 In dtTableReport.AsEnumerable
Group Join row2 In dtTableAvClass.AsEnumerable On row1(0).ToString Equals row2(0).ToString Into Group
From grp In Group.DefaultIfEmpty()
Select ra = row1.ItemArray.Take(2).Append(If(grp Is Nothing, Nothing,grp(1))).ToArray
Select dt_Output.Rows.Add(ra)).CopyToDataTable

Add this to an assign activity where left side is your output datatable and right is the above linq

Hi @Nguyen_Van_Luong1 thank you for your reply. not yet try with LinQ. thanks for the idea. i’ll get back to you

1 Like

Hope you success @arthurang
LinQ is best choice with big data

Hi @Nguyen_Van_Luong1 i’m sorry i’m not yet familiar with the LinQ query. can you give me some example on how to use LinQ? thank you.

Hi @arthurang ,
You can see some example about linQ of Mr.Peter
Profile - ppr - UiPath Community Forum

1 Like

@arthurang

This is the exact candidate for join activity

Use a join activity on dt1 and dt2…on the classID column …

If you are getting class_ID column twice use a filter datatable activity and then filter out the unwanted columns

Cheers

1 Like

with the linked case

we did it, with the key building blocks:

  • lookup realized with a dictionary
  • updating the rows within a parallel for each

[HowTo] LINQ (VB.Net) Learning Catalogue - Help / Something Else - UiPath Community Forum

1 Like

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