Ejemplo n.º 1
0
        protected virtual void configure(CommandBuilder sql, bool withStatistics)
        {
            if (Mode == StatementMode.CommonTableExpression)
            {
                sql.Append(Previous == null ? "WITH " : " , ");

                sql.Append(ExportName);
                sql.Append(" as (\n");
            }

            SelectClause.WriteSelectClause(sql, withStatistics);

            if (Where != null)
            {
                sql.Append(" where ");
                Where.Apply(sql);
            }

            writeOrderClause(sql);

            if (Offset > 0)
            {
                // TODO -- need to add more overloads to avoid the type to DbType lookup
                var param = sql.AddParameter(Offset);
                sql.Append(" OFFSET :");
                sql.Append(param.ParameterName);
            }

            if (Limit > 0)
            {
                var param = sql.AddParameter(Limit);
                sql.Append(" LIMIT :");
                sql.Append(param.ParameterName);
            }

            if (Mode == StatementMode.CommonTableExpression)
            {
                sql.Append("\n)\n");
            }
        }