It's quite common situation when the queries generated with EasyQuery components must have an additional condition(s) not visible to end-users. For example you may need to limit the result set by user ID, department ID or some time frames.
To insert extra conditions into generated SQL statements you can use BuildSQLEx()
function of SqlQueryBuilder
class (instead of BuildSQL
you are using by default) and pass necessary condition(s) in its second parameter. The value of that parameter will be added into result SQL statement at the end of WHERE clause with AND conjunction to conditions, defined by end-users through visual controls.
The only trick here - you may also need to list all tables which take part in that extra condition using ExtraTables
property of DbQuery class. It's necessary to ensure that all necessary table joins will be included into result SQL.
Example:
Korzh.EasyQuery.Db.Table table = model.Tables.FindByName("Customers"); query.ExtraTables.Add(table); SqlQueryBuilder builder = new SqlQueryBuilder(query); builder.BuildSQLEx("", "Customers.CustomerID = 'ALFKI'");