Convert IEntityCollection to String Array

Dear community,

is there an easier / shorter way to convert values from IEntityCollection to a string array? At the moment I'm filling in the string array by looping through the IEntity object like this:

...

    Dim colObjects As IEntityCollection = Session.Source.GetCollection(Query.From("PersonWantsOrg").Select("XObjectKey").Where(WhereClause))

        If colObjects.Count > 0 Then

            Dim arrXObjKey As String() = New String(colObjects.Count - 1) {}

            For Each colElement As IEntity In colObjects

                arrXObjKey(counterAttCase) = colElement.GetValue("XObjectKey").ToString

                counterAttCase += 1

            Next
...

Thanks in advance!

Kind regards,

Rinay

Parents Reply
  • A use case just converting the XObjectKey column value to an array could look like this.

    Public Function SDK_CollectionToArray() As String()
        Dim pwoQuery = Query _
                        .From(Table.PersonWantsOrg) _
                        .Where(Function(t) t.Column(Table.PersonWantsOrg.OrderState) = "OrderProduct") _
                        .Select("XObjectKey")
    
        Dim requestCollection = Session.Source.GetCollection(pwoQuery, EntityCollectionLoadType.Slim)
        
        Return requestCollection.Select(Of String)(Function(t) t.GetValue(Of String)("XObjectKey")).ToArraySmart()
    
    End Function

Children