Vlookup with linq

Hello everyone

I need some modifications for this linq query

(From a In collectionsDT.AsEnumerable()
Group Join b In AgeingDT.AsEnumerable
On a(“Bank Invoice”) Equals b(“Document Number”) Into gj = Group
From g In gj.DefaultIfEmpty
Let slsa = If(isNothing(g), Nothing, g(1))
Let rapre = a.ItemArray.Take(2).Append(slsa)
Let rapost = a.ItemArray.Skip(3)
Let ra = rapre.Concat(rapost).toArray
Select r=dtResult.Rows.add(ra)).CopyToDataTable()

This query returns only matched records but along with matched records i need to get not matching records also.

For example

Dt1

Num| mail
1 | abc@mail.com
2 | abc @mail1.com
3 |abc@mail2.com

Dt2
Num|mail
1 |abc@mail4.com
5 |abc@mail5.com

After using this vlookup linq i am getting output like this

Num| mail
1 | abc@mail4.com
2 |
3 |

But I need to get ouput not matching also

Num| mail
1 | abc@mail4.com
2 | abc @mail1.com
3 |abc@mail2.com

Anyone can please help me on this

@Anil_Rajavarapu1

Why dont you use a join activity directly(left join) and then a filter datatable to remove the columns that are not needed or retain only the columns needed

Cheers

No anil actually I am doing vlookup with linq
In one excel i have some data which I have mentioned in above one excel is having old data another excel is having new data i need to replace old data with new data using ling

mapping the linq and the samples we would conclude:

when there is no right pairing row, then use null. But we do feel that your intention is to use the existing left value.

can you try:
Let slsa = If(isNothing(g), a(ColNameOrIndexToEmail), g(1))

we assume that all other parts from the reused LINQ is clear and that the ItemArray reconstruction part is matching the involved datacolumn structures.

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