This is an old revision of the document!
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. EasyQuery provides you with 2 possible ways of resolving this task:
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.
Korzh.EasyQuery.Db.Table table = model.Tables.FindByName("Customers"); query.ExtraTables.Add(table); SqlQueryBuilder builder = new SqlQueryBuilder(query); builder.BuildSQLEx("", "Customers.CustomerID = 'ALFKI'");
Since version 3.5.0 of EasyQuery ASP.NET you can use more simple and convenient way of inserting extra conditions:
query.ExtraConditions.AddSimpleCondition("Customers.CustomerID", "Equal", "ALFKI");
Now there is no need to deal with
ExtraTables or use the exact SQL expression for your extra condition.
AddSimpleCondition method will take care about everything.