LinQ to Vlookup Two columns same Row

I have the following Table
image

I need to do a vlookup to giveme the index row base ond the value of two column if not exist give the value of -1
for example
Input
Value Column A = Calel
Value Column B = 3
Output
Index = 2
IValue Column A = Calel
Value Column B = 8
Output
index = -1

I know how to do it with the for each datatable activities but i want to do it in linq cause take less time to process

I am trying to study linq and i have this
DataTable.AsEnumerable()Where(Function(row) str_ColumnA.equals(row(“ColumnA”).ToString AND str_ColumnB.equals(row(“ColumnB”).ToString ))

HI,

Can you try the following sample?

dt.Rows.IndexOf(dt.AsEnumerable.Where(Function(r) r("ColumnA").ToString=a AndAlso r("ColumnB").ToString=b).FirstOrDefault)

Sample
Sample20240425-1.zip (9.5 KB)

Regards,

1 Like

Thank you so much Yoichi :slight_smile:

1 Like

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