How do I convert a generic list to a DataReader in.NET?

.net generic-list sqlbulkcopy sqldatareader winforms

Question

Hello, I've got a populated generic list in a winform, and I'd want to bulk copy the data onto a SQL server database. I discovered that a data reader is required as a source when I read the SqlBulkCopy Class.

How can I turn it into a DataReader now?

Many thanks

2
1
2/1/2011 8:29:39 AM

Accepted Answer

Then, you may send it to SqlBulkCopy by converting it to a DataTable. Due to the fact that all of the data is already in memory, it would be more simpler and would not affect speed.

Similar question may be found on SO.

4
5/23/2017 9:58:25 AM

Expert Answer

If the amount of data is rational enough to function as aList<T> , it would be better to simply build aDataTable and send the info in that direction. I don't 11-zzz-zzzzDataTable yet it fulfills this task well. Writing a custom essay would be an option.IDataReader implementation like as, but that repeatedly loops over the list's contents. I'm not sure whether the effort is worthwhile.

2
2/1/2011 8:33:17 AM


Related Questions





Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow