7.6. How to modify WHERE clause programmatically
There are two or more ways to cope with this task depending on the type of modification.
1. You may want to add specific criteria if the query contains specific tables and if such criteria it's not already added to the query, i.e. to analyze the existing query first.
In general, you should find the necessary datasource in the list of datasources in the query; if found, find or add the necessary field name to the list of expressions, then add or modify the condition for this expression. Read the Understanding complex SQL query structure representation, Enumeration of data sources and joins in a sub-query and Enumeration of output columns in a sub-query articles to learn the basics. Use the code sample from the QueryModificationDemo project to cope with this task.
2. You may want to append or replace the criteria string to the WHERE clause regardless of it's current content.
It is not possible just to join the new and old criteria strings with AND operator and put the result string back to the query, but it's possible to operate with internal query representation objects to do almost the same. Use the code sample from the AppendCriteriaStringDemo project to cope with this task.