load a List objet RRS feed

  • Question

  • User106761762 posted

    I wonder if we have a implementation like this , It does not cause an overhead? first we got a datatable and after that we convert this in a List object in order to retorn a List to the UI intead of returnig a Datatable, or this is a good practice.

    Public Function ListGenericArgLista(ByVal nombreprocedimiento As String, ByVal arg As Long) As List(Of Catalogo)
            ldt = Me.DatosSql.TraerDataTable(nombreprocedimiento, arg) 'this functions returns a datatable
            Dim listaCat As New List(Of Catalogo) 'this is my class
            If ldt.Rows.Count > 0 Then   'load a List
                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()
            End If
            Return listaCat

        End Function

    Wednesday, March 18, 2015 1:46 PM


All replies