CleanCode C# Libraries v0.9.23 API

DBHelper.SplitQuery Method 

Splits a compound query into two queries when you need to run a slightly different query because of fundamental incompatibilities.

public static void SplitQuery(
   String compoundQuery,
   out String& trueQuery,
   out String& falseQuery
);

Parameters

compoundQuery
Instrumented query to be split
trueQuery
Returned query instance on true condition.
falseQuery
Returned query instance on false condition.

Remarks

A typical example of this is if a new table is introduced in a later version, queries that reference that table will not be compilable in earlier versions. So this function acts as a macro pre-processor to split out the query into its two valid incantations. The query must be specially constructed, containing <IF>...<ELSE>...<END> constructs, each on a separate line. So they do not interfere with the query, each should be preceded with the comment indicator "--". Further, within the ELSE clause each line must be commented out with a comment indicator followed by a double-asterisk ("--**"). That allows the compound query to run without alteration, and is thus functionally equivalent to the returned trueQuery. Multiple instances of IF...ELSE...END may appear in the query.

See Also

DBHelper Class | CleanCode.Data Namespace