A Simple Query |
Scroll |
The ExecuteSimpleQuery operation allows you to conveniently specify a document query if your query meets the following conditions:
The query is executed in a single category (not a multi-query)
Conditions are specified for at most one category field.
Results are to be sorted by at most one category field.
If your query does not meet these conditions, you have to specify and execute a regular query. See ExecuteSingleQuery or ExecuteMultiQuery operations for more details.
1 |
Create a channel factory to the web service endpoint. |
2 |
Create a channel to the web service endpoint. |
3 |
Create request parameters. Please consult the documentation of the ExecuteSimpleQuery operation for more information on parameters and usage. |
4 |
Execute request on the server. |
5 |
Close the channel and channel factory. |
6 |
Display a message box with the results. |
// 1. Create a channel factory to the web service endpoint
...
ChannelFactory<IThereforeService> channelFactory = new ChannelFactory<IThereforeService>(binding, endpoint);
// 2. Create a channel to the web service endpoint
IThereforeService service = channelFactory.CreateChannel();
// 3. Create request parameters
ExecuteSimpleQueryParams parameters = new ExecuteSimpleQueryParams();
parameters.CategoryNo = CategoryIds.FilesCategory;
parameters.FieldNo = CategoryIds.Files_Extension;
parameters.Condition = "d*";
parameters.OrderByFieldNo = CategoryIds.Files_Extension;
// 4. Call the ExecuteSimple of a service
ExecuteSimpleQueryResponse response = service.ExecuteSimpleQuery(parameters);
// 5. Close the channel and channel factory.
((IClientChannel)service).Close();
channelFactory.Close();
// 6. Display a message box with the results.
string info = "Rows found: " + response.QueryResult.ResultRows.Count + Environment.NewLine;
response.QueryResult.ResultRows.ForEach( r => info += String.Format("Found document No: {0}, IndexValues count: {1}{2}", r.DocNo, r.IndexValues.Count, Environment.NewLine));
MessageBox.Show(info);