Is there a way to add an index to a datatable in .Net?
I have a datatable holding about 1,100 rows and the datatable.select statement seems a bit slow for an in-memory operation.
table.PrimaryKey = new DataColumn[]{table.Columns["column1"],table.Columns["column2"]}
when searching
table.Rows.Find(New Object[]{<value in column1>, <value in column2>})
This will return a datarow. Also the Primary key values must be unique, otherwise an exception will be thrown.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With