Example #1
0
        /// <summary>
        /// the same as render(), but ignoring 'order by' and 'limit offset'
        /// </summary>
        public override string renderInSelect()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("SELECT {0}", distinct ? "DISTINCT" : "");
            //select all
            if (tableFields == null && selectFields == null)
            {
                sb.Append(" * ");
            }
            //table fields
            if (tableFields != null)
            {
                foreach (DbTable t in tableFields)
                {
                    sb.AppendFormat(" {0}.* ,", t.Name);
                }
            }
            //fields
            if (selectFields != null)
            {
                foreach (expr exp in selectFields)
                {
                    sb.AppendFormat(" {0} ,", exp.Render(this));
                }
                sb.removeLastChar();
            }
            //from
            if (targetTable != null)
            {
                sb.AppendFormat(" FROM ({0}) ", targetTable.renderInSelect());
            }
            //where
            if (cond != null)
            {
                sb.AppendFormat(" WHERE ({0}) ", cond.Render(this));
            }
            //group by
            if (groupBys != null)
            {
                sb.Append(" GROUP BY ");
                foreach (expr ex in groupBys)
                {
                    sb.AppendFormat(" {0} ,", ex.Render(this));
                }
                sb.removeLastChar();
                if (havingExp != null)
                {
                    sb.AppendFormat(" HAVING ({0}) ", havingExp.Render(this));
                }
            }
            //
            return(sb.ToString());
        }
Example #2
0
 public override string renderInSelect()
 {
     return(string.Format("({0}) {1} JOIN ({2}) ON ({3})", Tbl1.renderInSelect(), joinNames[(int)join], tbl2.renderInSelect(), on.Render(null)));
 }