Execute() public method

Runs the Query and returns the number of results
public Execute ( ) : int
return int
Example #1
0
        protected virtual void TestQueryButtonClicked(object sender, System.EventArgs e)
        {
            // we're assuming that the source is a valid one.
            buttonOk.Sensitive = false;
            Candidate = null; // Erase any previous successful query candidate
            Query target = new Query();

            // Set the global source ID of the target's source
            target.SourceID = sourceSelector.Active - 1;

            // Start setting the parameters that will be set via the filters
            SearchParams queryParams = new SearchParams();

            // iterate over all the filters and get the filters
            foreach(Widget filterWidget in filterWidgets)
            {
                IFilterWidget filter = (IFilterWidget)filterWidget;
                if(filter != null)
                {
                    // modify the query parameters
                    filter.SetFilterParams(ref queryParams);
                }
            }

            target.Generator.queryParameters = queryParams;
            target.Generator.Title = bugTitleEntry.Text;

            // now try to run the query
            testQueryButton.Sensitive = false;
            int output = target.Execute();
            if(output == -1)
            {
                // the connection failed or something
                testQueryOutputLabel.Text = "The request to the server failed. Please try later";
                testQueryButton.Sensitive = true;
            }
            else
            {
                testQueryOutputLabel.Text = String.Format("The query returned {0} results", output);

                // Allow user to press OK button
                buttonOk.Sensitive = true;

                // Set the new candidate
                Candidate = target;

                testQueryButton.Sensitive = true;

            }
        }