>>So is there a reason you didn't create a new table an manually loop through the rows? You are trying to force LINQ to do something it wasn't designed to do (create a new DataTable with a different structure). If you need the results as a DataTable, it needs to have a structure defined so that DataRows can be created for it. If you don't want to do that, you could write a method that would convert an IEnumberable< object> to a DataTable. Or you could create a class to hold the results of your query and use that instead of a DataTable to pass the results to the other function.
>
>Agreed, not sure why it's coming back to a DataTable after being transformed. I thought it was going to be used as XML.
It is, but we have custom methods that generate the XML the way we want. These methods accept datatable and loop and use stringbuilder to produce XML string. The standard ToXml() method of DataSet will not work for us.
If it's not broken, fix it until it is.
My Blog