Datatable vs IEnumerable<T>? RRS feed

  • Question

  • Hi,

    I'm currently dealing with a scenario where I would get a bunch of data from the XML and upload it in to SQL db.

    Before uploading the data to the db, which is the good way to hold the data after I parse the XML? Datatable or IEnumerable List of custom objects?


    I have a gut feeling that List Objects would be light-weight and more elegant way of organizing the data with the strong typing than datatable. But the con is that I cant use BCP to upload the data if it is in List Objects and I wld eventually have to convert the data in to datatable format anyways?


    Any thoughts?


    Thanks in advance

    - Shashi
    • Edited by ShashiV Tuesday, September 20, 2011 8:32 PM
    Tuesday, September 20, 2011 8:32 PM


  • What is the purpose of holding it in an object?  Will you be querying on it or doing any manipulation of it before putting into SQL?  If so, it would be nice to have it in a generic list.

    If not, then I would not even bother loading it into an object of any type, but instead use SSIS to parse the XML and do a load into the database all at once.     

    Tom Overton
    • Marked as answer by ShashiV Wednesday, September 21, 2011 4:13 PM
    Tuesday, September 20, 2011 9:21 PM