Is there a way to use SqlBulkCopy without converting the data to a DataTable?

c# sqlbulkcopy sql-server

Question

Is there a way to use SqlBulkCopy without converting the data to a DataTable? I have a list of objects (List) in RAM and I really don't want to use more memory to create the DataTable. Could it be possible to implement IDataReader on a List?

Thanks!

Popular Answer

I would certainly imagine that you could. BulkDataReader requires schema information; that's why you can't simply provide a List. If you design a class that implements IDataReader, you'll be providing this in your GetSchemaTable implementation.

I would simply create a DataTable myself, unless I could demonstrate a real memory issue that would justify the implementation.



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