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?
this may work
DataTable table = DataProvider.GetTable()
var clientIds = (from r in table.AsEnumerable()
select r.Field<string>("CLIENT_ID")).ToList();
Here is one way to do it:
var clientIds = table.Rows.Cast<DataRow>().Select(r => r.Field<string>("CLIENT_ID").ToList();
Or, if this syntax is working but not bringing back the results as a list, you can do something like:
var clientIds = (from r in table.AsEnumerable()
select r.Field<string>("CLIENT_ID")).ToList();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.