A helper class used to assist in building valid SQL statements.

An instance of this class is passed in to the SearchScope.FetchObjects and SearchScope.FetchRows methods to perform a query.

The SearchSQL class can be used in either of the following ways:

  • Use the helper methods to specify the parts of the SQL statement. For example, use SetFromClauseInitialValue to set the name of the class being searched, SetSelectList to set the names of the properties to include, and SetWhereClause to specify what to search for. When the SearchSQL instance is passed in as an argument to SearchScope.FetchRows, the complete SQL statement string is constructed out of the parts supplied by the calls to the SearchSQL helper methods. You also can get the complete SQL statement string constructed by calling the ToString method.
  • Pass in a complete SQL statement. If you have the complete SQL statement that needs to be executed, pass the SQL statement into either the SetQueryString method or the SearchSQL(String) constructor. The SearchSQL instance is then complete, and no other SearchSQL method can be called on this instance.

The settings for the following properties can directly affect the search criteria:

  • ObjectStore.DefaultQueryTimeLimit
  • ObjectStore.MaxQueryTimeLimit
  • IServerCacheConfiguration.QueryPageMaxSize
  • IServerCacheConfiguration.QueryPageDefaultSize
  • IServerCacheConfiguration.NonPagedQueryMaxSize
Note
Date/Time values in queries are evaluated with respect to the Content Engine server clock. If the client and server clocks are not in sync, be careful when translating relative time concepts into absolute times. For example, specifying a value that means "within the last 5 minutes" on the client will translate to a comparison to an absolute time in the SQL query, which may not mean "within the last 5 minutes" relative to the server clock.

The following tables list the members exposed by SearchSQL.

Public Constructors

 NameDescription
StaticPublic methodSearchSQLOverloaded. Initializes a new instance of the SearchSQL class.
Top

Public Methods

 NameDescription
Public methodEqualsDetermines whether the specified Object is equal to the current Object. (inherited from Object)
Public methodGetHashCodeServes as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table. (inherited from Object)
Public methodGetTypeGets the Type of the current instance. (inherited from Object)
Public methodSetAllSpecifies that duplicate rows can be returned in the result set.
Public methodSetContainsRestrictionRestricts the query to return only items where the text in the content element or elements matches the specified String. This method uses the CONTAINS function for CBR (Content-Based Retrieval) queries.

The CONTAINS function can perform the search on CBR-enabled properties for the supported content elements in any of the following ways:

  • Search a single property.
  • Search all properties within a specified zone.
  • Search all properties.
Public methodSetDistinctRestricts the query to return only distinct rows. This setting is valid only when all properties in the select list are orderable (as specified in the ORDER BY clause).
Public methodSetFolderRestrictionRestricts the query to return only items from the specified class within the specified folder.
Public methodSetFreetextRestrictionRestricts the query to return only items where the text in the content elements matches the specified String. This method uses the FREETEXT function for CBR (Content-Based Retrieval) queries.

The FREETEXT function searches all content on all CBR-enabled properties on the supported content elements. To search content on a single CBR-enabled property, use SetContainsRestriction.

Public methodSetFromClauseAdditionalJoinAdds another class to the FROM clause used in the SQL statement.
Public methodSetFromClauseInitialValueSets the first class to be used in the FROM clause for the statement.
Public methodSetMaxRecordsSets the maximum number of rows that can be returned in the result set. When unspecified, all records that satisfy the query will be returned, subject to the limit of the IServerCacheConfiguration property NonPagedQueryMaxSize.
Public methodSetOrderByClauseSets the ORDER BY clause to be used for the SQL statement to the specified String.
Public methodSetQueryStringSpecifies the entire SQL statement. This method cannot be used in conjunction with any of the other Set methods on this class. Doing so will have the following effect:
  • Any values set by calling another SearchSQL Set method (such as, SetMaxRecords), then calling this method, will overwrite or nullify the value initially set.
  • Calling this method, then calling any other SearchSQL Set method will overwrite or nullify the SQL statement specified here.

No SQL validation is performed on the specified string.

Public methodSetSelectListSets the SELECT list for SQL statement to the specified String. This must be called prior to calling SetFromClauseAdditionalJoin.
Public methodSetTimeLimitSets the maximum duration the query runs on the server, in seconds. When unspecified, the value of the ObjectStore property DefaultQueryTimeLimit is used.

Warning: Date/Time values in queries are evaluated with respect to the Content Engine server clock. If the client and server clocks are not in sync, be careful when translating relative time concepts into absolute times. For example, specifying a value that means "within the last 5 minutes" on the client will translate to a comparison to an absolute time in the SQL query, which may not mean "within the last 5 minutes" relative to the server clock.

Public methodSetWhereClauseSets the WHERE clause to be used for SQL statement to the specified String.
Public methodToStringOverridden. Returns either the SQL statement constructed using the helper methods (in this case, SetFromClauseInitialValue must have been called prior to this method), or the SQL statement specified in its entirety using either SetQueryString or the SearchSQL(String) constructor.
Top

Protected Methods

 NameDescription
Family methodFinalizeAllows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (inherited from Object)
Family methodMemberwiseCloneCreates a shallow copy of the current Object. (inherited from Object)
Top

Explicit Interface Implementations

 NameDescription
StaticPrivate methodSearchSQLOverloaded. Initializes a new instance of the SearchSQL class.
Top

See Also