I have a 2 column table containing vehicleid's and descriptions.
I wish to filter out a single set of rows using the VehicleId.
The table will typically contain 6 rows per vehicleId and
upwards of 500 distinct vehicles therfore about 3000 rows approx.
The reason the table contains 6 rows per vehicleId is because it contains name/value information pairs about the vehicle.
My question is;
When using the DataView.Rowfilter method
- does setting a primary key column have any effect upon the filter,
i.e. Will it improve the filters speed or is it completely unnecessary ?
‘Get all vehicles.
‘returns 2 columns: VehicleId, Descr
Dim dt as datatable = GetVehicleData()
‘Create a primary key column.
Dim PriKeyCol() As DataColumn = Nothing
'Sets primary key for the table.
PriKeyCol(0) = dt.Columns.Item("VehicleId")
dt.PrimaryKey = PriKeyCol
dv.RowFilter = String.Concat("VehicleId=", VehicleId)
Dim dtVehicleDetails As DataTable = dv.ToTable
‘Bind dtVehicleDetails to some user interface control.
Before filtering the data typically looks like this: