创建ADO.NET数据视图只显示选定列 [英] Create ADO.NET DataView showing only selected Columns

查看:143
本文介绍了创建ADO.NET数据视图只显示选定列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在C#和放大器; .NET,可以创建一个数据视图仅包括一个的正确的子集的的DataColumn 第一个给定的数据表

In C# & .NET, can one create a DataView that includes only a proper subset of the DataColumns of a given DataTable?

在关系代数方面,一是分配的RowFilter 以进行选择操作(西格玛)。将如何执行投影操作(PI)?

In terms of relational algebra, one assigns a RowFilter in order to perform a "selection" operation (σ). How would one perform a "projection" operation (π)?

推荐答案

您不能这样做,但你可以创建表的只有列你想有一个副本:

You can't do that, but you can create a copy of the table with only the columns you want :

DataView view = new DataView(table);
DataTable table2 = view.ToTable("FirstColumn", "SecondColumn", "ThirdColumn");

您也可以选择返回具有不同值的选定列行:

Optionally you can return rows that have distinct values for the selected columns :

DataView view = new DataView(table);
DataTable table2 = view.ToTable(true, "FirstColumn", "SecondColumn", "ThirdColumn");

这篇关于创建ADO.NET数据视图只显示选定列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆