Hi I'm using PetaPoco lib and I have a method that loops through the elements of a list returned by a PetaPoco.DataBase.Query, the problem is that the list type is variable so I'm not able to access to the singleItem properties. The Query method used this way returns an ExpandoObject. I can determinate which type the list would be but I don't want to use a CASE statement inside the FOR loop.
Is there a way to pass the Type in the parameters and cast singleItem? or could I do something using Reflection?
Public Sub Test(ByVal Table As String, ByVal DB As PetaPoco.DataBaseDB)
For Each singleItem As Object In DataBase.Query(Of Object)("SELECT * FROM " & Table)
Next
End Sub
Thanks!
Aucun commentaire:
Enregistrer un commentaire