'Convert DBResult To Map of Maps.
'The key is the index value of each record
'The value is the map with all the fields of each record
'Example of use:
'Dim Records As Map = req.ToMapWithKeyField(res, "ean")
'Dim Record As Map = Records.GetDefault("6935364085469", Null)
'If Record.IsInitialized Then
' echo(Record.GetDefault("nombre","Fieldnotfound"))
'Else
' echo("Indexnotfound.")
'End If
public Sub ToMapWithKeyField(table As DBResult, keyfield As String) As Map
Dim maps As Map
maps.Initialize
For Each row() As Object In table.Rows
Dim nm As Map = CreateMap()
For Each col As String In table.Columns.Keys
'get index of column
Dim colIdx As Object = table.Columns.Get(col)
'get value row at index
Dim colVal As Object = row(colIdx)
nm.Put(col.tolowercase, colVal)
Next
maps.put(nm.Get(keyfield), nm)
Next
Return maps
End Sub