I have a method that is passed in an EnumerableRowCollection(Of System.Data.DataRow),i want to be able to use the underlying datatable. Ultimately i want to be able to use the columns collection of that datatable.
currently i use
Dim t As System.Data.DataTable = TryCast(x(0), DataRow).Table
where x is EnumerableRowCollection(Of System.Data.DataRow
)
This works fine, EXCEPT for the case where the count of rows is zero.
I am convinced that the underlying datatable definition is still there as i am able to access it through the debugger if i 'add watch' against x
in the watch window i see
x|{System.Data.EnumerableRowCollection(of System.Data.DataRow)}
System.Data.EnumerableRowCollection(of System.Data.DataRow)|{System.Data.EnumerableRowCollection(of System.Data.DataRow)}
ElementType| {Name="DataRow" FullName = "System.Data.DataRow"}
EnumerableRows|In-Memory Query
Table|{mydatatable}
It is mydatatable that i am after
if i try
x.Table
then i get
'table' is not a member of 'System.Collections.Generic.IEnumerable(Of System.Data.DataRow)'.
in my case the enumerablerowcollection is most likely being created from a datatable using LINQ with an orderby
Dim z = (From d In mydataset.mydatatable.OrderBy(Function(c) c.myfield))
In summary, i want to be able to access the datatable from an EnumerableRowCollection(Of System.Data.DataRow) even if the count of EnumerableRows is zero.
If this is not possible then please could you help me explain how teh watch window can display this. Am i allowed to add an image of what i am seeing in the watch window?
I have added the image of what the debugger shows, how does it get this table info