Existe uma maneira de iterar o objectResult? Ou seja Assim como iterar todas as colunas e linhas da tabela de dados sem especificar o nome da coluna.
Eu gosto de criar uma função genérica que irá exibir toda a coluna do resultado do objeto. Então, é possível conseguir isso?
Dim queryResults As Data.Objects.ObjectResult = CType(obj, Data.Objects.ObjectResult)
If Not (queryResults Is Nothing) Then
" Create the representation.
Dim result As New Dictionary(Of String, Object)
Dim enumerator As System.Collections.IEnumerator = Nothing
enumerator = DirectCast(queryResults, System.Collections.IEnumerable).GetEnumerator()
" Iterate through the query results.
While enumerator.MoveNext()
""How to get all columns ???
End While
" Dispose the enumerator
DirectCast(enumerator, IDisposable).Dispose()
Return result
End If
Return New Dictionary(Of String, Object)
Respostas:
0 para resposta № 1Tente desta maneira:
DataTable table = GetTable(); // Your Query to Get the data table.
foreach (DataRow row in table.Rows) // Loop over the rows.
{
foreach (var item in row.ItemArray) // Loop over the items.
{
Console.WriteLine(item);
}
}