Message 1 of 3
Add FeatureReader to acSelection
Not applicable
10-12-2011
01:49 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi there,
I'm trying to add all fdo layer features to MgSelectionBase so I can turn on/off map layer features depending on the selection query.
here is what I have:
AcMapLayer maplayer = AcMapFeatureEntityService.GetLayer(objId); //objId is from prompt selection
MgFeatureQueryOptions queryOpts = new MgFeatureQueryOptions();
queryOpts.SetFilter("PRIMARYINDEX > 0"); //select everything on the layer
MgResourceIdentifier fsId = new MgResourceIdentifier(maplayer.GetFeatureSourceId());
MgFeatureService fs = AcMapServiceFactory.GetService(MgServiceType.FeatureService) as MgFeatureService;
MgFeatureReader featureReader = fs.SelectFeatures(fsId, maplayer.FeatureClassName, queryOpts);
AcMapSelection selBaseAll = new AcMapSelection(AcMapMap.GetCurrentMap());
//populate selection with all features
selBaseAll.AddFeatures(maplayer, featureReader, 0);
//hide all features
maplayer.SetFeatureVisibility(selBaseAll, false);
.
.
//turn on features that is passed as parameter to fn.
This works if the layer source is SDF file, but if the layer source is sql spatial, i get an error "An exceotion occured in FDO component. Property "GwsId" not defined for class "Classname"". this is on line: selBase.AddFeatures(..);
That field "GwsId" doesn't exists in database, if you open it in sql studio.. what am I doing wrong?
Thank you,
-dm