Compare two column and update to another column through linq

linq.xlsx (8.3 KB)
Hello All,

I want to write linq query to check two column Col A and Col B "If Col A contains “Needed” and col B contains “TRUE” then update to Col c = “Present” else remaining are same as it. Please help me to find the solution.

Hi,

Hope the following sample helps you.

img20210611-2

dt = dt.AsEnumerable.Select(Function(r) dt.Clone.LoadDataRow({r("Col A"),r("Col B"),if(r("Col A").ToString.Contains("Needed") AndAlso r("Col B").ToString.ToUpper="TRUE","Present",r("Col C"))  ,r("Col D")},False)).CopyToDataTable

Sample20210611-2.zip (8.4 KB)

Regards,

1 Like

Thank you for your Help. Sample has work for me.

1 Like