Fastest way to convert datatable to generic list
Posted
by Joel Coehoorn
on Stack Overflow
See other posts from Stack Overflow
or by Joel Coehoorn
Published on 2009-01-13T22:08:10Z
Indexed on
2010/05/21
22:10 UTC
Read the original article
Hit count: 669
I have a data tier select method that returns a datatable. It's called from a business tier method that should then return a strongly typed generic List.
What I want to do is very similar (but not the same as) this question:
http://stackoverflow.com/questions/208532/how-do-you-convert-a-datatable-into-a-generic-list
What's different is that I want the list to contain strongly-typed objects rather than datarows (also, I don't have linq avaiable here yet).
I'm concerned about performance. The business tier method will in turn be called from the presentation tier, and the results will be iterated for display to the user. It seems very wasteful to add an extra iteration at the business tier, only do it again right away for the presentation, so I want this to be as quick as possible.
This is a common task, so I'm really looking for a good pattern that can be repeated over and over.
© Stack Overflow or respective owner