FUNCAO CLR - ARRAYLIST SÓ RETORNA A ULTIMA POSI?ÃO

FAABIIANOOC 10/01/2017 13:25:10
#470562
Caros, estou enfrentando dificuldades em obter valores de um array, ele me retorna somente o ultimo, alguém pode me ajudar a identificar onde estou errando?

  Imports Newtonsoft.Json
Imports System.IO
Imports System.Net
Imports Microsoft.SqlServer.Server

Partial Public Class WSMegaSena
<Microsoft.SqlServer.Server.SqlFunction(DataAccess:=DataAccessKind.Read, FillRowMethodName:=[Ô]FillRow[Ô], TableDefinition:=[Ô]NumeroConcurso nvarchar(max),Dezena nvarchar(max),DataRealizacao nvarchar(max)[Ô])> _
Public Shared Function fn_Retorna_ResultadoMS() As IEnumerable
Dim rowsArray As New ArrayList()
SetData(rowsArray)
Return rowsArray
End Function

Public Shared Sub FillRow(ByVal obj As Object, ByRef NumeroConcurso As String, _
ByRef Dezena As String, _
ByRef DataRealizacao As String
)
Dim row As Object() = DirectCast(obj, Object())


NumeroConcurso = DirectCast(row(0), String)
Dezena = DirectCast(row(1), String)
DataRealizacao = DirectCast(row(2), String)
End Sub

Public Shared Sub SetData(ByVal rowsArray As ArrayList)
Dim address As String = [Ô]http://wsloterias.azurewebsites.net/api/sorteio/getresultado/1[Ô]
Dim client As WebClient = New WebClient()
Dim reader As StreamReader = New StreamReader(client.OpenRead(address))
Dim json = (reader.ReadToEnd)
Dim objs As RootObject = JsonConvert.DeserializeObject(Of RootObject)(json)
Dim column As Object() = New Object(3) {}

Dim numeroConcurso As String = 0, Dezena As String = 0, DataRealizacao = [Ô][Ô]
Dim i As Integer = 0

For Each nums In objs.Sorteios
For Each ds In nums.Numeros
numeroConcurso = DirectCast(objs.NumeroConcurso.ToString, String)
Dezena = ds.ToString
DataRealizacao = DirectCast(objs.Data.ToString, String)
column(0) = numeroConcurso
column(1) = Dezena
column(2) = DataRealizacao
rowsArray.Add(column)

i = i + 1
Next ds
Next nums

End Sub
End Class
Faça seu login para responder