You are trying to typecase an IEnumerable<Waypoint>
as an IEnumerable<DataRow>
, which is not going to work unless your Waypoint
class is derived from DataRow
, which I assume it's not. The documentation for the CopyToDataTable
method is pretty clear:
The parameter T of the input parameter source can only be of type DataRow or a type derived from DataRow.
You are going to have to make your data table the long way, unfortunately. Make a new blank DataTable
, add columns to it's Columns
collection, then add rows to it's Rows
collection.