Search code examples
c#linqlinq-to-dataset

LINQ to DataSet to get generic list from DataTable


DataTable table = DataProvider.GetTable()

var clientIds = from r in table.AsEnumerable()
                select r.Field<string>("CLIENT_ID");

I want clientIds to be a List<string>. Currently it's an EnumerableRowCollection<>

What am I missing?


Solution

  • this may work

    DataTable table = DataProvider.GetTable()
    
    var clientIds = (from r in table.AsEnumerable()
                    select r.Field<string>("CLIENT_ID")).ToList();