Basically I’m converting a SQL datatable to a generic list which I can successfully do. But I can’t figure out how to return the the list object. I get a error that say’s a variation of- Cannot implicitly convert type System.Collections.Generic.IList to System.Collections.Generic.List
What would be the correct way to return theList as type List?
public List<MyObject> GetAllMyObjects()
{
String command = "select * from names ";
DataTable tableResult = DataTableToList.ExecuteDataTable(command, CommandType.Text, null,connectionString);
IList<MyObject> theList = DataTableToList.ConvertTo<MyObject>(tableResult);
return // I’m not sure how to return theList here...
}
Call
ToListon yourtheListobject.