Seek to a Record

Topics: Data Access, SharpMap Project, SharpMap v0.9 / v1.x
May 8, 2008 at 1:12 PM

I need a method to find a feature in a shapefile by searching with a attribute value. I make it like this:

uint iFeature = (uint)oShape.GetFeatureCount();
for (i = 0; i < iFeature; i++)
if (oShape.GetFeature(i)"Area".ToString().TrimEnd() == cArea)

But this is sequential and very slow in a shapefile with 20.000 feature.
Is there a method to find a record like an seek in xbase language with an index file?

I hope, anybody have a solution for me.

May 8, 2008 at 3:26 PM
You could try loading the entire thing into an ADO.Net DataTable. DataTables have indexes internally, so looking up attributes is much faster. 20,000 records shouldn't be a big problem - I've used DataTables with 10s of thousands of rows without difficulty.