Retornar una lista a la UI
Publicado por Alfredo (8 intervenciones) el 18/03/2015 19:35:30
ok, si tengo un mi capa de loginca del negocio el siguiente código, en donde tengo una función interna DAL que me retorna un DataTable, luego lo tomo y lo convierto en un objeto tipo List (of T), para retornar esta lista a a UI, pregunto esto no es redundante, no causa overhead, no retornamos el DataTable por que hemos leido que es más lento y consume más memoria. Este es mi código
Public Function ListarGenericoArgEnteroLista(ByVal nombreprocedimiento As String, ByVal arg As Long) As List(Of Catalogo)
ldt = Me.DatosSql.TraerDataTable(nombreprocedimiento, arg)
Dim listaCat As New List(Of Catalogo)
If ldt.Rows.Count > 0 Then
For Each row As DataRow In ldt.Rows
Dim regCat As New Catalogo
regCat.IdCatalogo = Convert.ToInt32(row("IDCATALODO"))
regCat.Orden = Convert.ToInt32(row("ORDEN"))
regCat.Descripcion = row("DESCRIPCION").ToString()
regCat.WebPage = row("WEBPAGE").ToString()
regCat.Estado = row("ESTADO").ToString()
listaCat.Add(regCat)
Next
End If
Return listaCat
End Function
Public Function ListarGenericoArgEnteroLista(ByVal nombreprocedimiento As String, ByVal arg As Long) As List(Of Catalogo)
ldt = Me.DatosSql.TraerDataTable(nombreprocedimiento, arg)
Dim listaCat As New List(Of Catalogo)
If ldt.Rows.Count > 0 Then
For Each row As DataRow In ldt.Rows
Dim regCat As New Catalogo
regCat.IdCatalogo = Convert.ToInt32(row("IDCATALODO"))
regCat.Orden = Convert.ToInt32(row("ORDEN"))
regCat.Descripcion = row("DESCRIPCION").ToString()
regCat.WebPage = row("WEBPAGE").ToString()
regCat.Estado = row("ESTADO").ToString()
listaCat.Add(regCat)
Next
End If
Return listaCat
End Function
Valora esta pregunta


0