我有一个DataSet,它有两个DataTable的关系。
这个Dataset是网格中的DataSource。
在我的应用程序的另一个站点,我使用这个DataSource作为DataTable。关系允许我使用ChildRelations。
我需要所有的DataRow在一个列表中。
第一部分是(DTpadre和DThijo是DataTables):
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 IEnumerable(Of我要Datarow). IEnumerable(Of
发布于 2019-03-28 20:39:24
a.ChildTable是DataTable。
a.ChildTable.Select()是对 method of DataTable的调用,它返回DataRow数组。
因此,结果类型是IEnumerable(Of an array of DataRow)。
如果要将所有子表的所有行都平顺到一个集合中,请使用SelectMany
Dim obj = DTprincipal.ChildRelations.Cast(Of DataRelation).SelectMany(Function(r) r.ChildTable.Select())https://stackoverflow.com/questions/55406262
复制相似问题