One Dataset for each DataTable or one Dataset for all DataTables?

那年仲夏 提交于 2020-01-07 04:37:51

问题


I am writing a C# application that uses Local DataSets. I have a DataSet for Customer Information, and a DataSet for Stocked Items. In regards to perfomance, and file size, would it be advisable to use just one DataSet with the Customer Infomation and the Stocked Items DataTables, or separate DataSets for each DataTable? I intend to use data to put into a report (using report viewer).


回答1:


The DataSet is built for, well just that, a set of data. It's built to allow you to create relationships between tables, provide cascading, and constraints. You should use data sets to group tables together when you are working with more than one table at a time. If you're not working with more than one table, get rid of the DataSet and just use a DataTable.

Now, if you're trying to cache all of the data locally, then that would make sense for all the tables to be in one DataSet where the data can be related and operated on together. Well, that is if you're operating on those tables together.

UPDATE: based on your comment about your intentions, it makes sense for all of the related data to exist in a single DataSet. The report is going to need to be able to know what rows are related and in what ways to handle grouping and such.



来源:https://stackoverflow.com/questions/21431757/one-dataset-for-each-datatable-or-one-dataset-for-all-datatables

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!