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 178943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:19:11+00:00 2026-05-11T14:19:11+00:00

I have an existing application that uses Active Record for its data retrieval. It’s

  • 0

I have an existing application that uses Active Record for its data retrieval. It’s in VB.NET (first time I’m doing VB.NET; I usually work in C#). And I’m building a method to return a List(Of T) of an object.

The current pattern uses a SQLDataAdapter to populate a datatable. I COULD add the record to the List(Of T) as I fill the datatable, but there HAS to be a better way to do this.

Any ideas? I’m not married to using SQLDataAdapter, if there’s a better way that avoids it…

  • 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. 2026-05-11T14:19:11+00:00Added an answer on May 11, 2026 at 2:19 pm

    As you’ve still not had any responses…

    I haven’t used Active Record myself, so I don’t know at what point that makes any kind of difference but it strikes me that reading into a DataTable and a List<T> is duplicating things somewhat.

    How about populating the List<T> from a SqlDataReader instead? As you move through the results using Read(), create a new object from the current row and add it to the list. If you need to do it for various different types, I’d write a generic method to do it, along the lines of:

    public static List<T> ToList<T>(this SqlDataReader reader,     Func<SqlDataReader, T> rowConverter) {     List<T> ret = new List<T>();     while (reader.Read())     {         ret.Add(rowConverter(reader));     }     return ret; } 

    Then you can implement the converter with a lambda expression or anonymous method.

    Alternatively you could make the extension method target the command instead of the SqlDataReader – it could deal with calling ExecuteReader, converting every row and then disposing of the reader afterwards.

    (It’s a slightly odd signature because SqlDataReader represents both the iterator and the current row; just a quirk of the API.)

    I’m probably missing something deeper though – if this doesn’t help, could you explain why, perhaps as a question edit?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 77k
  • Answers 77k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Try attaching it to the EventTrigger for the Datagrid. Something… May 11, 2026 at 3:33 pm
  • added an answer Other than virtualization, no. If you have the hardware to… May 11, 2026 at 3:33 pm
  • added an answer try three = (T.<*>) It's weird to define an infix… May 11, 2026 at 3:33 pm

Related Questions

I have an existing application that uses Active Record for its data retrieval. It's
I have an existing application that is written in C++ for Windows. This application
I have an existing asp.net webforms project that uses Microsoft's Enterprise DAAB for the
I have an intermittent problem with some code that writes to a Windows Event
I am working on a VB6 application that uses an ADODB.Recordset object to dump

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.