Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9168835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:43:34+00:00 2026-06-17T15:43:34+00:00

Please have a look at the following question, which i asked some time ago:

  • 0

Please have a look at the following question, which i asked some time ago: Breaking BLL (Business Logic Layer) to BLL and DAL (Data Access Layer)

This approach (Data Transfer Object) seems to work well if I am returning one record from the data access layer i.e. getNameByID returns one record.

What happens if you have a Data Access Layer function called getName(), which returns many records e.g. thousands or millions to be processed in the Business Logic Layer? (it is a scheduled task). When this is required I am currently returning a DataTable (because data readers cannot outlive a connection in VB.NET 2008). However, this question and answer seems to negate this approach: Is returning DataTable or DataSet from DAL is wrong approach. Is this a poor approach?

I realise there are ORM tools like NHibernate, which I plan to use more for future projects. However, the data access code in my current project is already written by someone else but I want to refactor it as I go along.

Update
Here is some code (as suggested by Stephen Doggart):

Imports Microsoft.VisualBasic

        Public Class PersonBLL
            Private Name As String
            Private Age As Integer

            Dim objPersonDAL As New PersonDAL
            Dim personList As List(Of Person)

            'Option 2
            Public Function getPersonByID() As List(Of Person)
                personList = objPersonDAL.getPersonByID()
                Return personList
            End Function



    Public Function ShowMessageBox(ByVal listPersonBLL As List(Of Person))
        For Each p As Person In listPersonBLL
            Me.Age = p.Age
            Me.Name = p.Name
            MsgBox(Me.Age)
            MsgBox(Me.Name)
        Next
    End Function

        End Class

        Public Class PersonDAL
            Private Name As String
            Private Age As Integer

            Public Function getPersonByID() As List(Of Person)
                'Connect to database and get Person.  Return a person object
                Dim personList As List(Of Person) = New List(Of Person)
                Dim p1 As New Person
                p1.Name = "Ian"
                p1.Age = 30
                personList.Add(p1)
                Dim p2 As New Person
                p2.Name = "Steven"
                p2.Age = 28
                personList.Add(p2)
                Dim p3 As New Person
                p3.Name = "Sharon"
                p3.Age = 29
                personList.Add(p3)
                Return (personList)
            End Function
        End Class

        Public Class Person
            Private _Name As String
            Private _Age As Integer

            Public Property Name() As String
                Get
                    Return _Name
                End Get
                Set(ByVal value As String)
                    _Name = value
                End Set
            End Property

            Public Property Age() As Integer
                Get
                    Return _Age
                End Get
                Set(ByVal value As Integer)
                    _Age = value
                End Set
            End Property
        End Class

    Public Class Form1

            Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
                'If Environment.GetCommandLineArgs(0) = "Test" Then
                'MsgBox("Test")
                'End If
                Dim p1 As PersonBLL = New PersonBLL
                Dim p2 As List(Of Person) = p1.getPersonByID()
                Dim p3 As PersonBLL = New PersonBLL
                p3.ShowMessageBox(p2)
            End Sub
        End Class
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T15:43:35+00:00Added an answer on June 17, 2026 at 3:43 pm

    Returning a DataTable isn’t completely terrible–there’s certainly worse ways of doing it–it’s only partly terrible. But, who wants to eat partly terrible food unless they have no other option?

    So, unless there’s some reason why you need to use a DataTable, I would recommend sticking with custom DTO classes and just have your DAL return a list of those objects. For instance:

    Public Function GetNames() As List(Of NameDto)
        '...
    End Function
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please have a look at the following question: Favor composition over inheritance The accepted
I have HttpClient 4.1. Please have a look at following program: import org.apache.http.client.methods.*; import
please have a look at the following code import java.util.ArrayList; import java.util.List; public class
Please have a look at the following code namespace Funny { class QuesionsAndAnswers {
Please have a look at the following code: $(#saveButton).click(function(){ $this = $(#tableData).find(input:checked).parent().parent(); tea =
Please have a look at the following machine code ‎0111001101110100011100100110010101110011011100110110010101100100 This means something. I
Please have a look at the following code package Euler; import java.util.ArrayList; import java.util.List;
In my current project, Workflows have comments. Please have a look at the following
am new here. i have a slight problem; PLease look at the following code
Recently I was asked the following interview question: You have two sets of numbers

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.