创建仅显示选定列的 ADO.NET DataView
在 C# 和 .NET,可以创建一个仅包含给定 DataTable 的 DataColumn
的适当子集的 DataView
?
就关系代数而言,分配一个RowFilter
以执行“选择”操作(σ)。 如何执行“投影”运算(π)?
In C# & .NET, can one create a DataView
that includes only a proper subset of the DataColumn
s of a given DataTable
?
In terms of relational algebra, one assigns a RowFilter
in order to perform a "selection" operation (σ). How would one perform a "projection" operation (π)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
好吧,我看不出“想要”这样做的任何理由...记住,DataView 只是指向原始表中行的指针列表,显然没有办法从原始表中删除列...至少不会影响使用该表的所有其他功能...只需使用您想要的列...
Well I can't see any reason for "wanting" to do that... Remember, a DataView is just a list of pointers to the rows in the original table, and there is obviously no way to remove columns from the the original table... at least not without affecting every other function utilizing that table... Just only use the columns you want...
您不能这样做,但您可以创建仅包含所需列的表副本:
您也可以选择返回对所选列具有不同值的行:
You can't do that, but you can create a copy of the table with only the columns you want :
Optionally you can return rows that have distinct values for the selected columns :
创建 dataview 作为从一个表到另一表的交换,并使用 dtswap 作为数据源。
create dataview as a swap from one table to other table, and use the dtswap as datasource.
DataSet
及其关联类型无法执行关系操作。DataSet
and its associated types have no ability to perform relational operations.