无法在linq中使用CopyToDataTable返回数据集

无法在linq中使用CopyToDataTable返回数据集,linq,datatable,linq-to-dataset,Linq,Datatable,Linq To Dataset,如何从.NET3.5中的linq返回数据集 我在一些网站上看到使用了CopyToDataTable方法,但我无法使用该方法,因为我在ref列表中找不到System.data.datatableextensions引用。 请帮帮我 感谢和问候, veena直接从中复制。在询问之前尝试搜索 // Fill the DataSet. DataSet ds = new DataSet(); FillDataSet(ds); DataTable orders = ds.Tables["SalesOrd

如何从.NET3.5中的linq返回数据集

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

感谢和问候, veena直接从中复制。在询问之前尝试搜索

// 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;

这也适用于VB.NET,只是您必须将查询变量声明为IEnumerableOf DataRow,而不是只放置Dim关键字