What is the difference between dataview and datatable?(数据视图和数据表有什么区别?)
问题描述
.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.
这篇关于数据视图和数据表有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:数据视图和数据表有什么区别?
基础教程推荐
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- rabbitmq 的 REST API 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- c# Math.Sqrt 实现 2022-01-01