Linq query to update cell of a row item based on another cell value from same row

Hello all,

I have a requirement for which i need to implement linq query , i am sharing the requirement below :
I have 2 data tables dt_invoice&Comments , and dt_master
first data table dt_invoice has invoce numbers lets say A101,A102,A103 etc. in invoice column and second column for the dt_invoice&comments has comments.
I need to search each invoice of dt_invoice&comments in dt_Master data table , whenever a match found in second data table i.e, dt_master, i have to update a cell value for found invoice in the dt_master, this cell value is nothing but the comment we have in dt_invoice&comments for the respective invoice.

Can someone suggest how to build linq query for the same.

Appreciate your help, in advance.

Regards,
Shiva

1 Like

have a look here for the basic concepts:

once the joining / pairing / lookup is cleared we can translate it to a linq

For LINQ Practice have a look here:

Hi,

Try this:-

Assign activity to get list of query:-

query = from DataRow invoiceRow in dt_invoiceComments.Rows
join DataRow masterRow in dt_master.Rows
on invoiceRow[“invoice”] equals masterRow[“invoice”]
select new { Invoice = invoiceRow[“invoice”], Comment = invoiceRow[“comment”], MasterRow = masterRow };

Then use for each, item in a query

Assign activity
item.MasterRow[“your_cell_column_name”] = item.Comment;

Thanks

Thanks for sharing! , this will really helps.

Hi,
I am glad that it helps you… :slight_smile:
Please mark this as a solution. So others can refer the same.

Thanks