数据视图和数据表有什么区别? [英] What is the difference between dataview and datatable?

查看:34
本文介绍了数据视图和数据表有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

.Net 中的 DataView 和 DataTable 有什么区别?据我了解,DataView 只是对 DataTable 的虚假介绍.什么时候应该使用 DataView?

What is the difference between DataView and DataTable in .Net? As far as I understand DataView is just a false presentation of DataTable. When should I use DataView?

提前致谢.

推荐答案

当您想要运行查询并在控件中显示数据子集时,DataView 可以帮助您.这只是一个例子,看看 DataView 的 MSDN 示例,它解释了应该在哪里使用 DataViews 和 DataTables...

When you want to run a query and show the subset of data in a control, a DataView could help you. That's just one example, look at the MSDN example for DataView, that explains where you should use DataViews with DataTables...

数据表

数据表是单个数据库表的内存表示.您可以将其视为具有相同方式的列和行.DataTable 是 ADO.NET 库中的中心对象.其他使用 DataTable 的对象包括 DataSet 和 DataView.

A datatable is an in-memory representation of a single database table. You can think of it as having columns and rows in the same way. The DataTable is a central object in the ADO.NET library. Other objects that use the DataTable include the DataSet and the DataView.

看看 MSDN 的 DataTable 类 了解更多详情.

Look at MSDN The DataTable class for more details.

数据视图

数据视图是数据表上的视图,有点像 sql 视图.它允许您对行进行过滤和排序 - 通常用于绑定到 Windows 窗体控件.

A dataview is a view on a datatable, a bit like a sql view. It allows you to filter and sort the rows - often for binding to a windows form control.

此外,可以自定义 DataView 以显示来自 DataTable 的数据子集.此功能允许您将两个控件绑定到同一个 DataTable,但显示不同版本的数据.例如,一个控件可能绑定到显示表中所有行的 DataView,而第二个控件可能被配置为仅显示已从 DataTable 中删除的行.DataTable 还有一个 DefaultView 属性,它返回表的默认 DataView.

Additionally, a DataView can be customized to present a subset of data from the DataTable. This capability allows you to have two controls bound to the same DataTable, but showing different versions of the data. For example, one control may be bound to a DataView showing all of the rows in the table, while a second may be configured to display only the rows that have been deleted from the DataTable. The DataTable also has a DefaultView property which returns the default DataView for the table.

看看 MSDN DataView类了解更多详情.

Look at MSDN DataView class for more details.

这篇关于数据视图和数据表有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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