如何dataset
从linq
.net 3.5 中返回一个?
我在一些网站上看到使用了CopyToDataTable方法,但我无法使用该方法,因为我在参考列表中找不到 System.data.datatableextensions 参考。请帮帮我。
谢谢和问候,维娜
如何dataset
从linq
.net 3.5 中返回一个?
我在一些网站上看到使用了CopyToDataTable方法,但我无法使用该方法,因为我在参考列表中找不到 System.data.datatableextensions 参考。请帮帮我。
谢谢和问候,维娜
这也适用于 VB.NET,只有你必须将查询变量声明为 IEnumerable(Of DataRow) 而不是只放置 Dim 关键字。
直接从这里复制。在询问之前尝试搜索
// Fill the DataSet.
DataSet ds = new DataSet();
FillDataSet(ds);
DataTable orders = ds.Tables["SalesOrderHeader"];
IEnumerable<DataRow> query =
from order in orders.AsEnumerable()
where order.Field<DateTime>("OrderDate") > new DateTime(2001, 8, 1)
select order;
DataTable boundTable = query.CopyToDataTable<DataRow>();
bindingSource.DataSource = boundTable;