如何从数据集添加值的列表? [英] How to add values from Dataset to a List?
本文介绍了如何从数据集添加值的列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
string str = "Select bd_id from [Active]";
ds = new DataSet(str);
da = new SqlDataAdapter(str, con);
da.Fill(ds);
我想补充一点,我得到的是ID'S的形式列表中的数据集:
I want to add the dataset that i get that is a List of ID'S in the form:
bd_id
1
2
3
到泛型列表作为项目
Into a generic LIST as Items
我要如何去这样做的一样吗?
How do i go about doing the same?
推荐答案
Makue使用的LINQ to DATATABLE 会很容易做到,你的任务。
Makue use of LINQ to DATATABLE will do you task easily.
DataTable dtDetails = ds.Table[0];
List<int> lstExcelCurrencyCode =
(from dr in dtDetails.AsEnumerable()
select dr.Field<int>("bd_id")).ToList<int>();
这篇关于如何从数据集添加值的列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文