I am struggling to get the code right for my following requirement:
Requirement:
To have the name of datacolumns from a datatable in an array Except the ones whose Ordinal exist in lstSnapshotExcludingCols i.e. a list of integers.
Can someone please help me in getting the expected results. I am using the following code, but it returns all of the datacolumns and does not skip anything.
Dim columnNames = ldtCurrentData.Columns.Cast(Of DataColumn)()
.SkipWhile(Function(column)
lstSnapshotExcludingCols.Contains(column.Ordinal))
.Select(Function(column) column.ColumnName).ToArray()
I have the similar issue while selecting the data from a datarow:
Dim fields = row.ItemArray.SkipWhile(Function(value, index) lstSnapshotExcludingCols.Contains(index))
Don’t user
SkipWhile(...). A simpleWhere(...)will do the trick: