Possible to use dataset as ref

折月煮酒 提交于 2019-12-11 04:57:54

问题


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

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