LINQ query to vlookup data from one data table to another

Hello Friends,

I have two files Input and Output, in which Invoice Number column is same in both, I need to match Invoice number and add only Reference column data from Output file to Matching column in Input File, I want to keep original data with all columns in Input File

Anybody can help for LINQ query for this.

Hi @Pramod_Mangale ,

You can use Join activity and do left join using invoice number. Then you can use following query to take required columns.

dt_Final = dt_Join. DefaultView.ToTable(False, Join(“,”(From dc In InputDt.Columns.Cast(Of DataColumn) Select dc.ColumnName).ToArray()),”Reference No”)

Hope this helps.

1 Like

@Pramod_Mangale

Actually best would be to use join datatable and then a filter datatable to get only required columns as output and this is as good as linq query

Cheers