I am trying to use the function found here:
DataTable to List<object>
public static IList<T> ConvertTo<T>(DataTable table)
{
if (table == null)
return null;
List<DataRow> rows = new List<DataRow>();
foreach (DataRow row in table.Rows)
rows.Add(row);
return ConvertTo<T>(rows);
}
the return statement is giving me an exception stating:
The best overloaded method match for 'Utilities.Utility.ConvertTo<T>(System.Data.DataTable)' has some invalid arguments
Can someone help me fix this error??
Don’t do it that way use Marc’s amazing function ( https://stackoverflow.com/a/545429/215752 ) I mean really… that is exactly what you want.. right?
You need another function
The question you link had a link in it. I’d suggest looking there for more info:
http://lozanotek.com/blog/archive/2007/05/09/Converting_Custom_Collections_To_and_From_DataTable.aspx
There you will find all the code, which I expect will compile. I won’t vouch for the reliability or reasonably of using it however.