/// <summary> /// Build the sql for the query /// </summary> /// <param name="eqp"></param> /// <returns></returns> public override string BuildSql( ExecuteQueryParms eqp) { string sql = ""; Eqp = eqp; if (Eqp == null) { DebugMx.DataException("Eqp parameter is null"); } Qt = eqp.QueryTable; if (Qt == null) { DebugMx.DataException("Eqp.QueryTable is null"); } MetaTable mt = Qt.MetaTable; if (mt == null) { DebugMx.DataException("Metatable not defined for CalcField Query Table"); } Query q = eqp.Qe.Query; QueryTableData[] qtd = eqp.Qe.Qtd; // query table data QueryColumn qc; MetaColumn mc; KeyMc = mt.KeyMetaColumn; if (KeyMc == null) { throw new Exception("Key (compound number) column not found for MetaTable " + mt.Name); } KeyQci = Qt.GetQueryColumnIndexByName(KeyMc.Name); KeyQc = Qt.QueryColumns[KeyQci]; KeyQc.Selected = true; // be sure key is selected Qt.MetaTable.KeyMetaColumn.ColumnMap = ""; // reset key column mapping Query q2 = InitializeSubQuery(Qt); foreach (QueryTable qtx in q2.Tables) { // todo... } return(sql); }