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

发布于 2024-09-11 02:13:04 字数 196 浏览 2 评论 0原文

如何从.net 3.5中的linq返回数据集

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

谢谢和问候, 维纳

how to return a dataset from linq in .net 3.5?

I have seen in some sites that CopyToDataTable method is used but I am not able to use that methos as I cannot find System.data.datatableextensions reference in the ref list.
Please help me out.

Thanks and regards,
veena

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

在风中等你 2024-09-18 02:13:04

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

Which also goes for VB.NET, only you have to declare query variable as IEnumerable(Of DataRow) instead putting only Dim keyword.

若言繁花未落 2024-09-18 02:13:04

直接从此处复制。询问之前尝试搜索

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

Copied Directly from here. Try to search before asking

// 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;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文