This project is read-only.


Feb 24, 2011 at 11:25 PM
Edited Feb 26, 2011 at 12:08 PM


I'm trying to use featureset.SelectByAttribute. My filter is fs1.SelectByAttribute("[CLE]= 'AF327'"). I got an error "KeyNotFoundException" at line :

result.AddRange(rows.Select(dr => FeatureLookup[dr])); "Key was missing in the dictionary".

Of course, CLE is one of the shp columns. CLE is indexed.

Furthermore, if I write

dim dr() as datarow

dim datab as datatable


dr=datab.Select("[CLE]= 'AF327'")

I get one datarow.

I found that the previous line in dospatial.selectByAttribute function :

DataRow[] rows= dt.Select(filterExpression); return the same row.

So the problem comes from "FeatureLookup[dr]"

As I don't know C#, I would appreciate if someone could explain to me the purpose of this line "result.AddRange(rows.Select(dr => FeatureLookup[dr]));"

I understand that it's to return the row list but I don't understand how this "dr => FeatureLookup[dr]" works

As I found that FeatureLookup.keys=0, I wonder if it couldn't come from a key that must be added to the lookup table but don't know how.

Much thanks for any help,


PS : I tried a workaround doing a followed by a fs1.featurefromrom but then encounter again this KeyNotFoundException !!

My workaround so far is to use IfeatureLayer.Dataset.Find which works.

Jun 15, 2011 at 9:16 AM

Possible solution (workaround):