问题
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