0

I have a typed DataTable generated by Visual Studio from a database schema and I would like to populate it from a CSV file.

I have seen a solution for a plain DataTable but it wouldn't work for a typed DataTable.

Obviously I could read a DataTable first and then copy it row-by-row, field-by-field into my typed DataTable but I was hoping for a more elegant solution.

Sergey Slepov
  • 1,861
  • 13
  • 33
  • 1) You've tagged your question [tag:csvhelper] but none of the answers to your [linked question](https://stackoverflow.com/q/1050112/3744182) actually use this [library](http://joshclose.github.io/CsvHelper/). Which answer(s) from that question have you tried and do not work? 2) What have you tried so far and where are you stuck? – dbc Dec 20 '17 at 18:15

1 Answers1

1

I don't recall any library does it for you out of the box. If you are looking an answer how to convert DataTable to Typed Datatable, here is one approach

DataTable data = GetDataFromCSV();
MyTypedDataTable myData = new MyTypedDataTable();
myData.Merge(data);

Hope this helps.

Cinchoo
  • 6,088
  • 2
  • 19
  • 34