Linq Query to Update 500+ rows in datatable based on column name Product = DL-LS and column name Location starts with "R" then update the Status as " GOOD"

Filter Datatable based on column Product = DL-LS and column Location starts with R then update the Status as " GOOD"

Input
Id Name Date Product Document # Location Status
1 30110 BRIAN LAMBERT 4/1/2021 8:13 DL-LS 34507 R 1004 DIAM
3 30110 CHRIS LAROCHELLE 3/29/2021 4:55 QL-LS 21089301 Q 212 MAIN
3 30110 CHRIS LAROCHELLE 3/31/2021 13:02 WL-LS 21091011 W 212 MORRIS
6 30102 MARIA LUTZ 3/30/2021 5:25 RL-LS 58836 W 1216 GRAN WINNIPEG
9 30102 RYAN HAZELWOOD 4/2/2021 9:50 DL-LS 126968 R 1425 MCPHILLIPS ST
Output
Id Name Date Product Document # Location Status
1 30110 BRIAN LAMBERT 4/1/2021 8:13 DL-LS 34507 R 1004 DIAM Good
9 30102 RYAN HAZELWOOD 4/2/2021 9:50 DL-LS 126968 R 1425 MCPHILLIPS ST Good

NIVED_NAMBIAR Hi Bro is it possible to help me in this linq query

Hi,

Hope the following helps you.

newDt =dt.AsEnumerable.Where(Function(r) r("Product").ToString="DL-LS" AndAlso r("Location").ToString.StartsWith("R")).Select(Function(r) dt.Clone.LoadDataRow({ r("Id"),r("Name"),r("Date"),r("Product"),r("Document #"),r("Location"), "Good"},False)).CopyToDataTable

Sample20210415-1.zip (2.7 KB)

Regards,

1 Like

Thanks bro

1 Like