Do ADO.Net DataTables have indexes?

前端 未结 11 2177
别那么骄傲
别那么骄傲 2021-01-01 15:11

I am using VSTS 2008 + C# + .Net 3.5 + SQL Server 2008 + ADO.Net. If I load a table from a database by using a DataTable of ADO.Net, and in the database table, I defined a c

11条回答
  •  情书的邮戳
    2021-01-01 15:27

    The correct answer here is to create a DataView from the DataTable, which according to the doc will create an index:

    DataView constructs an index. An index contains keys built from one or more columns in the table or view. These keys are stored in a structure that enables the DataView to find the row or rows associated with the key values quickly and efficiently. Operations that use the index, such as filtering and sorting, see signifcant performance increases. The index for a DataView is built both when the DataView is created and when any of the sorting or filtering information is modified. Creating a DataView and then setting the sorting or filtering information later causes the index to be built at least twice: once when the DataView is created, and again when any of the sort or filter properties are modified.

提交回复
热议问题