custom types on the fly

Cadenzo

Active Member
Licensed User
Longtime User
I did not want it to put to wishlist, because it's more just an idea than a wish and it is not only related to one of the platforms. Especially when I make a db-request it is good to get the response in a custom type that matches the table columns. But if I have many different requests, it is not the best way, to create so many types, that are only used in one codeline.
B4X:
Sub Globals
    Type TestType1(id As Int, state As Int, name As String)
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Dim tt() As TestType1
    tt = GetDBResponse("some filter")
    For Each t As TestType1 In tt
        If t.status = 0 Then
            'do something
        End If
    Next
End Sub

Sub GetDBResponse(where As String) As TestType1()
    'SQL-Request
    'returns all rows from the request
End Sub

So the first idea was, to think about a keyword, that creates a type indirectly from a given db table. This is for sure problematic, because the IDE could not have always enough information in the design time about the table and its column types.

But what about declaring custom types on the fly like this?
B4X:
Sub GetDBResponse(where As String) As customtype(id As Int, state As Int, name As String)
   'SQL-Request
   'returns all rows from the request
End Sub
 
Top