DataRowに特定の値が含まれていないデータ行の抽出について

Continuing the discussion from 特定の値が含まれているデータ行の抽出について:

こんにちは。
いつもお世話になっております。
この構文を若干修正し、dt->dr(DataRow)に変更し、
DataRow列名に「コード」が含まれている列から「Z」が入力されていないデータ行の場合にTrueを返す条件文に変更して、DataRowをインデックスをカウントアップしながら回す処理の中で使いたいです。
下記で動作しますでしょうか。

dr.AsEnumerable.Where(Function(r) not dr.Columns.Cast(Of DataColumn).Select(Function(dc) dc.ColumnName).Where(Function(s) s.Contains(“コード”)).Any(Function(s) r(s).ToString=“Z”))

Hi @gorby

dr.AsEnumerable().Where(Function(r) Not dr.Columns.Cast(Of DataColumn)().Select(Function(dc) dc.ColumnName).Where(Function(s) s.Contains("Code")).Any(Function(s) r(s).ToString() = "Z")).ToList()

Output DataType of above syntax is List(Of DataRow)

=> If you want a single DataRow as output, you can modify the code to return the first DataRow that meets the condition:

dr.AsEnumerable().FirstOrDefault(Function(r) Not dr.Columns.Cast(Of DataColumn)().Select(Function(dc) dc.ColumnName).Where(Function(s) s.Contains("Code")).Any(Function(s) r(s).ToString() = "Z"))

Output DataType of above syntax is DataRow

Hope it helps!!

Hi Thank for your suggestion.
However, the next error message appearred after applying your suggested syntax.

“AsEnumerable is not a member of DataRow”

Hope your improved suggestion!

Hi @gorby

Check the below image for better understanding

Hope it helps!!

You did not answer my question.
Will you pls convert the subject from dr to dr_DataRow?
My requirement is to manipulate dr_DataRow NOT dr.

The next sentence is my requirement.
DataRow列名に「コード」が含まれている列から「Z」が入力されていないデータ行の場合にTrueを返す条件文に変更して、DataRowをインデックスをカウントアップしながら回す処理の中で使いたいです。