DataTable table = DataProvider.GetTable()
var clientIds = from r in table.AsEnumerable()
select r.Fi开发者_如何学JAVAeld<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();
精彩评论