XmlIndexQueryQuery Method (ConnectionId, SessionId, CategoryId, String, XmlIndexQueryQueryAggregate, String, NullableBoolean, Boolean, Boolean, Boolean, DateTime, String, XmlIndexQueryQueryDataTypes, Boolean, Int32, Int32, Int32, Int32, Int32) Content Studio 5.7 SDK
Content Studio Web Content Management System

[This is preliminary documentation and is subject to change.]

Performs a query against the Content Studio Xml index and optionally returns data.

Namespace: ContentStudio.Document.EPT
Assembly: CSServer5 (in CSServer5.dll) Version: 5.7.5016.0 (5.7.5016.0)
Syntax

public string Query(
	ConnectionId connectionId,
	SessionId sessionId,
	CategoryId categoryId,
	string filter,
	XmlIndexQueryQueryAggregate aggregateType,
	string sortCommand,
	Nullable<bool> draftsOnly,
	bool ignorePublishStatus,
	bool checkForReadPermission,
	bool returnExtendedFields,
	DateTime previewDate,
	string[] fieldNames,
	XmlIndexQueryQueryDataTypes[] dataTypes,
	bool[] returnData,
	int rangeSize,
	int pageNumber,
	int pageSize,
	out int pageCount,
	out int recordCount
)

Parameters

connectionId
Type: ContentStudioConnectionId
A value that identifies the web site
sessionId
Type: ContentStudio.SecuritySessionId
A value that identifies the user's session. This value usually originates from a call to OpenSession(ConnectionId).
categoryId
Type: ContentStudio.DocumentCategoryId
The category that contains data to filter on.
filter
Type: SystemString
The filter to use. This should be written as the WHERE clause in an SQL statement with field names surrounded with brackets. E.g. [myfield]=2 AND [yourField] BETWEEN 10 AND 20. The syntax of this filter is checked for Sql-injection attacks and will throw an exception if any statement not valid is passed in.
aggregateType
Type: ContentStudio.Document.EPTXmlIndexQueryQueryAggregate
Indicates if and how the query should be aggregated.
sortCommand
Type: SystemString
The SQL command that defines the sort instruction for the returned data. This must be sql e.g. [myfield] DESC that is valid within the ORDER BY clause and must be valid against the passed in field names. All field names must appear between brackets. The syntax of this filter is checked for Sql-injection attacks and will throw an exception if any statement not valid is passed in.
Tip
You can get a random search order by using the NEWID() clause.
draftsOnly
Type: SystemNullableBoolean
Indicates if the filter should filter against draft content rather than approved content. Pass null (Nothing in Visual Basic) to filter against the draft or the approved content, if draft was not found.
ignorePublishStatus
Type: SystemBoolean
Set this to true to ignore the Published flag to improve performance. Note that unpublished documents will be included in the result with this parameter set to true.
checkForReadPermission
Type: SystemBoolean
Tells if the method should check for write permission instead of browse.
returnExtendedFields
Type: SystemBoolean
Indicates if extra information data fields should be returned. Normally this parameter should be false
previewDate
Type: SystemDateTime
A DateTime that specifies a point in time to filter. With this value it is possible to take the publish date functionality into consideration. e.g. it is the possible to see how the site looks tomorrow when a new set of items exists. Use DataTime.MinValue to avoid using this functionality.
fieldNames
Type: SystemString
An array that contains the field name to filter on. These names must exist in the EPT schema and must be indexed. This parameter cannot contain more than PARAMETER_COUNT members.
dataTypes
Type: ContentStudio.Document.EPTXmlIndexQueryQueryDataTypes
An array that indicates what data type the each field in the FieldNames parameter contains. Default is String which always works. This value is only used when sorting data. Note if you use any other value that String the entire underlying Xml data must be in this data format if not an exception occurs. This parameter cannot contain more than PARAMETER_COUNT members.
returnData
Type: SystemBoolean
A boolean array that indicates which of the fields in the FieldNames parameter array should return data. This parameter cannot contain more than PARAMETER_COUNT members.
rangeSize
Type: SystemInt32
Defines the page range size. This property can be used to limit the number of records processed before returning the result. If value is zero, Content Studio processes all possible records before returning the result. If this value is greater than zero only the records that fits into that page range is processed but the total number of records found will be undefined. For example if the PageSize is 10 and the RangeSize is 5 Content Studio will evaluate 50 records maximum since this is the number of records that fit into that range.
pageNumber
Type: SystemInt32
The page number to read. If this value is less than 1 PageNumber will be 1.
pageSize
Type: SystemInt32
The size of the pages to read. If this parameter is less than 1 PageSize will be 10.
pageCount
Type: SystemInt32
The total pages of data found
recordCount
Type: SystemInt32
The total entries found

Return Value

Type: String
Xml with the following sample syntax.
Xml
<root>
  <status>0</status>
  <statustext>Success</statustext>
  <pageno>1</pageno>
  <pagesize>5</pagesize>
  <pagecount>1</pagecount>
  <recordcount>1</recordcount>
  <rows>
    <row documentid="1242" Introduction="Content Studio 5 " Header="Web Content Management easier that ever!" />
    <!-- more row items can follow -->
  </rows>
</root>
The code that fetched this content has been exemplified in the Example section. Note that the number of attributes in the row element is depending on the number of fields returned.
Exceptions

ExceptionCondition
CSExceptionA business rule was violated in the underlying Content Studio database
SqlExceptionAn error occurred when executing the command against the Content Studio database
Content Studio permissions

BROWSE permission on the documents selected is required if DraftsOnly is false otherwise READ permission is required. If permission on meta data is applied on the document category additional permissions on connected documents may apply.
Remarks

The XmlFilter class provides a much more user friendly way of programming against the Content Studio Xml filter.
Examples

The following example shows how to perform a simple filter query in Content Studio.
C#
int CategoryID = 168;
XmlIndexQuery query = new XmlIndexQuery();
int PageCount, RecordCount;
string xml = query.Query(CS_ConnectionId,
                         CS_UserSessionId,
                         CategoryID,
                         "[ContentType] = '1173'",
                         XmlIndexQuery.QueryAggregate.None,
                         "[CS_PublishDate] DESC",
                         false,
                         false,
                         true,
                         false,
                         DateTime.MinValue,
                         new string[4] { "Introduction", "Header", "ContentType", "CS_PublishDate" },
                         new XmlIndexQuery.QueryDataTypes[4] { XmlIndexQuery.QueryDataTypes.String, 
                                                               XmlIndexQuery.QueryDataTypes.String, 
                                                               XmlIndexQuery.QueryDataTypes.String,
                                                               XmlIndexQuery.QueryDataTypes.DateTime},
                         new bool[4] {true, true, false, false},
                         1,
                         1,
                         5,
                         out PageCount,
                         out RecordCount);
Visual Basic .NET
Dim CategoryID As Integer = 168
Dim query As XmlIndexQuery = New XmlIndexQuery()
Dim PageCount, RecordCount As Integer
Dim Fields As String(3) = New String(3) {"Introduction", "Header", "ContentType", "CS_PublishDate"}
Dim RetData As Boolean(3) = New Boolean(3) {True, True, False, False}
Dim Qdt As XmlIndexQuery.QueryDataTypes(3) = New XmlIndexQuery.QueryDataTypes(3) {XmlIndexQuery.QueryDataTypes.String, _
                                                                                  XmlIndexQuery.QueryDataTypes.String, _
                                                                                  XmlIndexQuery.QueryDataTypes.String, _
                                                                                  XmlIndexQuery.QueryDataTypes.DateTime}
Dim xml As String = query.Query(CS_ConnectionId,
                                CS_UserSessionId,
                                CategoryID,
                                "[ContentType] = '1173'",
                                XmlIndexQuery.QueryAggregate.None,
                                "[CS_PublishDate] DESC",
                                False,
                                False,
                                True,
                                False,
                                DateTime.MinValue,
                                Fields,
                                Qdt ,
                                RetData,
                                1,
                                1,
                                5,
                                PageCount,
                                RecordCount)
See Also

Reference