0

如何datasetlinq.net 3.5 中返回一个?

我在一些网站上看到使用了CopyToDataTable方法,但我无法使用该方法,因为我在参考列表中找不到 System.data.datatableextensions 参考。请帮帮我。

谢谢和问候,维娜

4

2 回答 2

1

这也适用于 VB.NET,只有你必须将查询变量声明为 IEnumerable(Of DataRow) 而不是只放置 Dim 关键字。

于 2010-09-28T13:37:04.703 回答
-2

直接从这里复制。在询问之前尝试搜索

// 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;
于 2010-07-22T06:43:24.700 回答