[V8i SS3 C#] Query Feature from Database inside a fence


i use the Function

// Method used to perform a query instances of a particular feature class using an optional attribute filter. 
        public void querySingleClass(string featureName, string whereClause, BGU.SpatialArea spatialFilterMode)
            // Get the open import criteria.
            BGU.IImportCriteria criteria = GDI.GeoDataInterchangeAddIn.Instance.MasterFileImport;

            if (criteria == null)

            // Set spatial filter criteria.
            criteria.Geometry = null;

            // You can use the SpatialArea property with All, Fence, or View. Don't use Selection, that's for export.
            criteria.SpatialArea = spatialFilterMode;

            // Get the storage import.
            BGU.IStorageImportCriteria storageImp = criteria.StorageImports[0] as BGU.IStorageImportCriteria;
            if (storageImp == null)

            // Deselect all feature classes.
            foreach (BGU.IClassImportCriteria currentClassImp in storageImp.ClassImports.Values)
                currentClassImp.Selected = false;

            // Select the feature class(es) you want to query.
            BGU.IClassImportCriteria classImp = storageImp.ClassImports[featureName] as BGU.IClassImportCriteria;
            if (classImp != null)
                classImp.Selected = true;

            // Optionally add a where clause for the selected feature classes.
            if (whereClause != null && whereClause.Length > 0)
                classImp.WhereClause = whereClause;

            // Execute the query.
            GDI.GeoDataInterchangeAddIn.Instance.ImportOrExport(criteria, null, true, true);

To query data from the database with a fence.

Is it possible to get only that objects, which are inside the fence? By default all object who are inside and overlapping the fence are written into the active model?

best regards

Martin Roling