将 IEnumerable(Of DataRow()) 转换为 List(Of Datarow)
Transform IEnumerable(Of DataRow()) into List(Of Datarow)
我有一个 DataSet
和两个 DataTable
的关系。
这个 Dataset
是我在网格中的 DataSource
。
在我的应用程序的其他站点中,我将此 DataSource
用作 DataTable
。该关系允许我使用 ChildRelations
.
我需要一个列表中的所有 DataRow
。
第一部分是(DTpadre
和DThijo
是DataTable
):
DS = New DataSet()
DS.Tables.Add(DTpadre.Copy)
DS.Tables.Add(DThijo.Copy)
DS.Relations.Add("PERMISOS", DS.Tables(0).Columns("CORR"), DS.Tables(1).Columns("CORR_PADRE"), False)
gridDetallePerfiles.DataSource = DS.Tables(0)
我试过的是:
DTprincipal = DirectCast(gridDetallePerfiles.DataSource, DataTable)
Dim obj = (From a As DataRelation In DTprincipal.ChildRelations() Select a.ChildTable.Select())
但是obj
是IEnumerable(Of <strong>DataRow()</strong>)
...我想要IEnumerable (<strong>数据行</strong>)
.
a.ChildTable
是 DataTable
.
a.ChildTable.Select()
是调用DataTable
的Select()
method即returns一个DataRow
的数组。
因此,结果类型是 IEnumerable(Of <em>DataRow</em> 的数组)
.
如果要将所有子表的所有行展平到一个集合中,请使用 SelectMany
:
Dim obj = DTprincipal.ChildRelations.Cast(Of DataRelation).SelectMany(Function(r) r.ChildTable.Select())
我有一个 DataSet
和两个 DataTable
的关系。
这个 Dataset
是我在网格中的 DataSource
。
在我的应用程序的其他站点中,我将此 DataSource
用作 DataTable
。该关系允许我使用 ChildRelations
.
我需要一个列表中的所有 DataRow
。
第一部分是(DTpadre
和DThijo
是DataTable
):
DS = New DataSet()
DS.Tables.Add(DTpadre.Copy)
DS.Tables.Add(DThijo.Copy)
DS.Relations.Add("PERMISOS", DS.Tables(0).Columns("CORR"), DS.Tables(1).Columns("CORR_PADRE"), False)
gridDetallePerfiles.DataSource = DS.Tables(0)
我试过的是:
DTprincipal = DirectCast(gridDetallePerfiles.DataSource, DataTable)
Dim obj = (From a As DataRelation In DTprincipal.ChildRelations() Select a.ChildTable.Select())
但是obj
是IEnumerable(Of <strong>DataRow()</strong>)
...我想要IEnumerable (<strong>数据行</strong>)
.
a.ChildTable
是 DataTable
.
a.ChildTable.Select()
是调用DataTable
的Select()
method即returns一个DataRow
的数组。
因此,结果类型是 IEnumerable(Of <em>DataRow</em> 的数组)
.
如果要将所有子表的所有行展平到一个集合中,请使用 SelectMany
:
Dim obj = DTprincipal.ChildRelations.Cast(Of DataRelation).SelectMany(Function(r) r.ChildTable.Select())