To convert DataTable to Generic List collection, use below approach
public IEnumerable<Person> LoadCollections()
{
DataTable table = LoadAll();
var list = (from DataRow row in table.Rows
select new Person
{
Active = bool.Parse(row["Active"].ToString()),
AutoId = int.Parse(row["Active"].ToString()),
FirstName = row["FirstName"].ToString(),
LastName = row["LastName"].ToString()
}).AsEnumerable();
return list;
}
Here LoadAll() method is giving me data from database into
table variable.
Person is my object that should be returned in the list.