Select a column form DataTable using 'like' operator

Hello,

I have a Data Table dtData and I need to check that all the values of a specific column are nulls (0.00)

The column’s name might change slightly like “fund”, “funds”, “funding”, “fundings”.

For now I use this query to check the values

dtData.AsEnumerable().All(Function(x) x.IsNull("Fund") OrElse x.Field(Of Double)("Fund") = 0.00)

Is it possible to modify the query in order to take the column like ‘fund’ ?

Hi @SONYC

dtData.Columns.Cast(Of DataColumn)().
       Where(Function(col) col.ColumnName.ToLower().Contains("fund")).
       All(Function(col) dtData.AsEnumerable().All(Function(row) row.IsNull(col) OrElse row.Field(Of Double)(col) = 0.00))

Regards,

Thank you very much @lrtetala

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.