Queries support the ability to bind the results to the object type, rather than the predefined IObject, ResultObject, or PartialObject. This works by serializing the resulting object to a JSON string. You can then pass your own function delegate to convert the JSON string into your own object type.
The following example uses the JSON deserialize function. However, you can implement the JSON deserialization in anyway required. This matches the object UID onto your custom object type.
Dim lcolResults As ICollection(Of CustomObjectType) = lobjDynamicQuery.ExecuteWithResultFactory(Of CustomObjectType)(AddressOf CreateResult(Of CustomObjectType))
Your example delegate function looks like this.
Protected Function CreateResult(Of T)(pstrJson As String) As ICollection(Of T)
Return TryCast(JsonConvert.DeserializeObject(Of T())(pstrJson), T())
End Function
This maps to our CustomObjectType, which has just one property.
Public Class CustomObjectType
<JsonProperty("ObjUID")>
Public Property UID() As String
Get
Return m_UID
End Get
Set(value As String)
m_UID = Value
End Set
End Property
Private m_UID As String
End Class
The <JsonProperty("ObjUID")> attribute tells the deserializer to map the JSON value of ObjUID to the property UID on the CustomObjectType.