How to check the column value is null and update with string using linq query

Hi,

Having dt and need to check the comments column is empty, if it is empty then update value as “No record” in the same table using linq query.

Ex:

User Date Time Comments
123 10/15/2024 19:03:34 Changed
121 10/16/2024 19:03:34 Updates
129 10/18/2024 19:05:34 commit
127 10/19/2024 9:11:23
120 10/20/2024 8:22:20
125 10/17/2024 19:05:20

output:

User Date Time Comments
123 10/15/2024 19:03:34 Changed
121 10/16/2024 19:03:34 Updates
129 10/18/2024 19:05:34 commit
127 10/19/2024 9:11:23 No record
120 10/20/2024 8:22:20 No record
125 10/17/2024 19:05:20 No record

TIA

Try using the below Linq Query:
dt.AsEnumerable().Where(Function(row) String.IsNullOrEmpty(row(“Comments”).ToString())).ToList().ForEach(Sub(row) row(“Comments”) = “No record”)

Here dt represents datatable variable.

Getting above error

Try using the below expression as these expression expect a return value.

For Each row In dt.AsEnumerable().Where(Function(row) String.IsNullOrEmpty(row(“Comments”).ToString())).ToList()
row(“Comments”) = “No record”
Next

Hi @Manaswini_UI

Please try to use this linq query in invoke code activity

dtInput.AsEnumerable().Where(Function(row) String.IsNullOrEmpty(row("Comments").ToString())).
ToList().ForEach(Sub(row) row("Comments") = "No record")

2 Likes