ESRI.ArcGIS.ADF.IMS
WhereExpression Property
See Also  Example
ESRI.ArcGIS.ADF.IMS.Carto.Layer Namespace > Filter Class : WhereExpression Property




Gets or sets the where expression.

Syntax

Visual Basic (Declaration) 
Public Property WhereExpression As String
Visual Basic (Usage)Copy Code
Dim instance As Filter
Dim value As String
 
instance.WhereExpression = value
 
value = instance.WhereExpression
C# 
public string WhereExpression {get; set;}

Example

This example creates a Filter and sets its WhereExpression. For another example of using a WhereExpression in a query on a map layer, see FeatureLayer.Query.

C#Copy Code
Filter queryFilter = new Filter(); 

queryFilter.WhereExpression = "POPULATION > 5000"; 

    
Visual BasicCopy Code
Dim queryFilter As New Filter()

queryFilter.WhereExpression = "POPULATION > 5000"

Remarks

WhereExpression enables selecting features based on values of attributes in the layer.

General information

  • The following operators work in a WhereExpression: =, >, >=, <, <=, <>, LIKE, BETWEEN, IN, NOT IN.
  • The following are not valid: ORDER BY and DISTINCT.
  • When creating a WhereExpression, two fields from the same attribute table can be used for comparison. For example, a query can be made to find states with a female population greater than the male population.

    WhereExpression="COUNTRY.STATE.FEMALES &gt; COUNTRY.STATE.MALES"

  • Queries can dynamically join attribute tables to the spatial layer. See JoinTables and JoinExpression for details.

  • WhereExpression is required if JoinTables is set and you are applying the filter to an ArcSDE layer.

Performance Considerations

When querying ArcSDE layers, performance is generally better when fields used in a WhereExpression are indexed. Indexing can be set up in ArcCatalog by connecting to the ArcSDE layer.

Shapefiles are not queried using attribute indexes. Query performance will generally be lower when shapefiles have large numbers of features and/or have large numbers of attribute fields.

Querying with dates - Image Services

The syntax for querying dates is the same regardless of the locale. A date query uses the following syntax:

{ts 'YYYY-MM-DD hh:mi:ss'}

where

YYYY Year Required Use four digits for the year.
MM Month (01-12) Required Use two digits for the month. March is 03.
DD Day (01-31) Required Use two digits for the day. The fourth is 04.
hh Hour (00-23) Optional Use a 24-hour clock. 8 a.m. is 08, and 8 p.m. is 20.
mi Minutes (00-59) Optional Use two digits for the minutes. If minutes is used, hours must also be included.
ss Seconds (00-59) Optional Use two digits for the seconds. If seconds is used, hours and minutes must also be included.

The year, month, and day are each separated by a dash (-). The hour, minutes, and seconds are each separated by a colon (:). The date is enclosed in single quotes (') inside curly brackets ({}). Before the date, ts (for time stamp) must be included.

For 8:03:23 a.m. January 4, 2000, the query on a DBF file looks like:

WhereExpression="MYDATE = {ts '2000-01-04 08:03:32'}"

For 9:18 p.m. March 8, 2002, the query on an ArcSDE layer looks like:

WhereExpression="ARCSDE.TABLE.MYDATE = {ts '2002-03-08 21:18:00'}"

Querying with dates - ArcMap Image Services.

A date query uses the same syntax as you would use in ArcMap. The format differs depending on the data type that the map is referencing:

Dates in coverages, shapefiles and ArcSDE geodatabases comply with SQL standards. The following example searches for January 31, 2003:

WhereExpression="DATE_ = date '2003-01-31' "

Dates in personal geodatabases are delimited like the following example:

WhereExpression="[DATE_] = #2003-01-31# "

Native database supported date formats may also be used when working with ArcSDE geodatabases

See Also

© 2010 All Rights Reserved.