问题
i have multiple dataset that is using on multiple form . so i make the dataset as public and store this on my Mdiparent form . when i open any form i use this call the dataset on child form and bind that dataset with my combobox . There are 20 dataset that are using on the form . So due to this load time take near about 30 - 35 seconds . So i want to use that dataset as ref
. How can i do this . Below the code that i am using right now
On Form Parent
public DataSet dszip = null;
dszip = _forderdac.GetZipPostal();
On Child form
DataSet dszip = dsAddr.Copy();
cmboboxZip.DataSource = dszip.Tables[0];
Thanks for your comments and advice.
回答1:
A DataSet
is a Reference Type
by nature. Value Types
are primitive types like int
, bool
, double
, long
, etc.
DataSet
is not the better approch to transfer data. You could use generics
collections like List<T>
and create a class (a DTO object for sample) which contains just the properties you need to bind into the form. With this you can get a better performance.
You could be sure if your query itno database to fill this dataSet is good query.
This article explain with some detail why is better using generics collections instead dataset. http://msdn.microsoft.com/en-us/magazine/cc163751.aspx
来源:https://stackoverflow.com/questions/27837892/possible-to-use-dataset-as-ref