.NET DataTable 的最佳用例是什么?

发布于 2024-07-12 07:55:15 字数 431 浏览 3 评论 0原文

我有三张表 客户、工作、订单

我在数据集中也有这些表,它符合与数据库本身相同的约束。

最初,我的意图是将数据保留在 DataSet 中,并创建各种 DataView 对象来向用户显示此数据,并执行任何所需的操作,然后显然会使用 .NET TableAdapter 方法将其更新回数据库。

然而,DataView 对象似乎只能对单个 DataTable 对象进行操作。

我的问题是:哪种是在内存中创建数据以确保可维护性和性能的最佳方式。

  1. 创建包含非规范化数据的多个 DataTable 对象。 这可能会在内存中创建数据的副本,但我更担心在更改时更新数据库会出现问题。
  2. 创建一些自定义类,它的行为方式与我期望的 DataView 的行为方式相同,并且还能够自动更新 DataSet(然后是数据库)。

I have three Tables
Customers, Jobs, Orders

I Also have these tables in the a DataSet, which conforms to the same constraints as those in the Database itself.

Originally, my intention was to keep the Data in the DataSet, and create various DataView objects to display this data to the user, and also to perform any required manipulations, which will then obviously be updated back on the database using the .NET TableAdapter methodology.

However, it seems as though DataView objects are only able to operate on a sigle DataTable object.

My question is this: Which is the best way to create data in memory to ensure maintainability and performance.

  1. Create multiple DataTable objects that contain the denormalized data. This would presumably create copies of the data in memory, but I'm more concerned that there would be issues with updating the database on changes.
  2. Create some custom Class which acts the way I expected DataView to act, and is also capable of automatically updating the DataSet (and then the database).

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

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

发布评论

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

评论(1

美男兮 2024-07-19 07:55:15

只需与原始数据集进行数据绑定即可。 您已经拥有所有数据,创建单独的数据表将使跟踪数据的更改变得非常困难。 在此处查找有关数据绑定父/子关系的一些提示

Simply databind with the original DataSet. You already have all the data and creating seperate DataTables will make it very hard to keep track of the changes to the data. Look here for some hints on databinding parent/child relations.

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