如何将DataTable.Select()结果传递给新的DataTable? [英] How to pass DataTable.Select() result to a new DataTable?
本文介绍了如何将DataTable.Select()结果传递给新的DataTable?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 DataTable
命名为 dt2
与数据。我正在调用其选择
方法来获取一些特定的行。
I have a DataTable
named dt2
with data. I am calling its Select
method to get some specific rows.
DataRow[] foundRows;
expression = "parent_id=1";
foundRows = dt2.Select(expression);
如何传递选择
-method导致新的 DataTable
- 说 FilteredData
?
How can I pass the Select
-method result to a new DataTable
– say FilteredData
?
推荐答案
您可以使用 CopyToDataTable
,可在 IEnumerable< DataRow>
类型中。
var filteredData = dt2.Select(expression).CopyToDataTable();
这篇关于如何将DataTable.Select()结果传递给新的DataTable?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文