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.


Hope the following sample helps you.


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 (8.4 KB)


1 Like

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

1 Like