C# DataSet Index

巧了我就是萌 提交于 2019-12-11 07:46:31

问题


I need to find records in a dataset that have certain values from more than 1 column. I cannot use the Find or Contains method since they require a primary key and my search values can be non-unique. Do DataSets have indexes (Much like a SQL table) that I can use to speed up my search? Right now I'm looping through the dataSet doing compares for each column but this method is very very slow (my data set has 600k rows).

Thanks


回答1:


You can use the DataTable Select method which lets you search according to a search criteria

DataRow[] myRows = ds.Tables[0].Select("intCol=0 OR stringCol='yourSearch'");


来源:https://stackoverflow.com/questions/722095/c-sharp-dataset-index

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