AutoCAD Map 3D 2009 Geospatial Platform Reference

AutoCAD Map 3D Geospatial Platform API

void MgFeatureQueryOptions::SetFilter ( CREFSTRING  filterText  ) 

Sets the filter for this select operation. The filter acts like the where clause in an SQL Select statement. Not calling this method causes all instances of the feature class to be selected. For more details on defining filters, see the Filter and Expression documentation.

.NET Syntax
void SetFilter(string filterText);
Java Syntax
void SetFilter(String filterText);
PHP Syntax
void SetFilter(string filterText);

Parameters:
filterText (String/string) The filter text to be applied.
Returns:
Returns nothing.
Example (PHP)
 <?php
 $queryOption->SetFilter("featId > 20");
 $featureService->SelectFeatures($featureSrcResourceId, $featClassName, $queryOptions);
 ?>
 sqlplus> select * from featclass where featId > 20;

 <?php
 $featureService->SelectFeatures($featureSrcResourceId, $featClassName, $queryOptions);
 ?>
 sqlplus> select * from featclass;

Exceptions:
MgInvalidArgumentException 
Example (C#)
 using OSGeo.MapGuide;
 private MgFeatureQueryOptions queryOptions;
 private MgFeatureService featureService;
 private String className = "SdfFeatureClass";
 // the SDF file identified by this MgResourceIdentifier exists in the repository
 private MgResourceIdentifier resourceId;
 private MgFeatureReader featureReader;

 resourceId = new MgResourceIdentifier("Library://PlatformApiDocTests/SdfFeatureClass.FeatureSource");
 queryOptions = new MgFeatureQueryOptions();
 queryOptions.AddFeatureProperty("FeatId");
 queryOptions.AddFeatureProperty("anInt32");
 queryOptions.SetFilter("anInt32 + 1 < 2");
 featureReader = featureService.SelectFeatures(resourceId, className, queryOptions);