The dataTable.Columns property cannot be queried with LINQ because it's a DataColumnCollection. Such a collection implements IEnumerable, but it's not a IEnumerable<DataColumn>, and therefore must be cast as such:
List<string> columnNames = (from c in dataTable.Columns.Cast<datacolumn>() select c.ColumnName).ToList();
No comments:
Post a Comment