Ejemplo n.º 1
0
        /// <summary>
        /// 获取选择语句内容
        /// </summary>
        /// <param name="baseCommand">源选择语句</param>
        /// <param name="orderReverse">是否反转排序</param>
        /// <returns>选择语句内容</returns>
        internal static String InternalGetPagerCommand(SelectCommand baseCommand, Boolean orderReverse)
        {
            SqlCommandBuilder sb = new SqlCommandBuilder(baseCommand.Database);

            sb.AppendSelectPrefix();

            sb.AppendSelectDistinct(baseCommand.UseDistinct).AppendAllColumnNames(baseCommand.UseDistinct, baseCommand.InternalGetQueryFieldList());
            sb.AppendSelectFromAndJoins(baseCommand.TableName, baseCommand.IsFromSql, baseCommand.InternalGetJoinList());

            sb.AppendWhere(baseCommand.WhereCondition);
            sb.AppendSelectGroupBys(baseCommand.InternalGetGroupByFieldList());
            sb.AppendHaving(baseCommand.InternalGetHavingCondition());
            sb.AppendSelectOrderBys(baseCommand.InternalGetOrderList(), orderReverse);

            if (baseCommand.PageSize > 0 && baseCommand.RecordStart <= 0)
            {
                sb.AppendSelectLimit(baseCommand.PageSize);
            }
            else if (baseCommand.PageSize > 0 && baseCommand.RecordStart > 0)
            {
                sb.AppendSelectLimit(baseCommand.RecordStart, baseCommand.PageSize);
            }

            return(sb.ToString());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取选择语句内容
        /// </summary>
        /// <param name="cmd">选择语句类</param>
        /// <param name="realPageIndex">实际页索引</param>
        /// <param name="realPageCount">实际页数量</param>
        /// <param name="orderReverse">是否反转排序</param>
        /// <returns>选择语句内容</returns>
        internal static String InternalGetSelectCommand(SelectCommand cmd, Int32 realPageIndex, Int32 realPageCount, Boolean orderReverse)
        {
            SqlCommandBuilder sb = new SqlCommandBuilder(cmd.DatabaseType);

            sb.AppendSelectPrefix();

            sb.AppendSelectDistinct(cmd.UseDistinct).AppendAllColumnNames(cmd.QueryFields);
            sb.AppendSelectFromAndJoins(cmd.TableName, cmd.IsFromSql, cmd.SqlJoins);

            sb.AppendWhere(cmd.SqlWhere);
            sb.AppendSelectGroupBys(cmd.GroupByColumns);
            sb.AppendHaving(cmd.SqlHaving);
            sb.AppendSelectOrderBys(cmd.SqlOrders, orderReverse);

            if (cmd.PageSize > 0 && cmd.PageIndex == 1)
            {
                sb.AppendSelectLimit(cmd.PageSize);
            }
            else if (cmd.PageSize > 0 && cmd.PageIndex > 1)
            {
                sb.AppendSelectLimit(cmd.PageSize * (realPageIndex - 1), cmd.PageSize);
            }

            return(sb.ToString());
        }
        /// <summary>
        /// 获取选择语句内容
        /// </summary>
        /// <param name="cmd">选择语句类</param>
        /// <param name="realPageIndex">实际页索引</param>
        /// <param name="realPageCount">实际页数量</param>
        /// <param name="orderReverse">是否反转排序</param>
        /// <returns>选择语句内容</returns>
        internal static String InternalGetSelectCommand(SelectCommand cmd, Int32 realPageIndex, Int32 realPageCount, Boolean orderReverse)
        {
            SqlCommandBuilder sb = new SqlCommandBuilder(cmd.DatabaseType);
            sb.AppendSelectPrefix();
            
            sb.AppendSelectDistinct(cmd.UseDistinct).AppendAllColumnNames(cmd.QueryFields);
            sb.AppendSelectFromAndJoins(cmd.TableName, cmd.IsFromSql, cmd.SqlJoins);

            sb.AppendWhere(cmd.SqlWhere);
            sb.AppendSelectGroupBys(cmd.GroupByColumns);
            sb.AppendHaving(cmd.SqlHaving);
            sb.AppendSelectOrderBys(cmd.SqlOrders, orderReverse);

            if (cmd.PageSize > 0 && cmd.PageIndex == 1)
            {
                sb.AppendSelectLimit(cmd.PageSize);
            }
            else if (cmd.PageSize > 0 && cmd.PageIndex > 1)
            {
                sb.AppendSelectLimit(cmd.PageSize * (realPageIndex - 1), cmd.PageSize);
            }

            return sb.ToString();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 获取选择语句内容
        /// </summary>
        /// <param name="baseCommand">源选择语句</param>
        /// <param name="orderReverse">是否反转排序</param>
        /// <returns>选择语句内容</returns>
        internal static String InternalGetPagerCommand(SelectCommand baseCommand, Boolean orderReverse)
        {
            SqlCommandBuilder sb = new SqlCommandBuilder(baseCommand.Database);
            sb.AppendSelectPrefix();
            
            sb.AppendSelectDistinct(baseCommand.UseDistinct).AppendAllColumnNames(baseCommand.QueryFields);
            sb.AppendSelectFromAndJoins(baseCommand.TableName, baseCommand.IsFromSql, baseCommand.SqlJoins);

            sb.AppendWhere(baseCommand.SqlWhere);
            sb.AppendSelectGroupBys(baseCommand.GroupByColumns);
            sb.AppendHaving(baseCommand.SqlHaving);
            sb.AppendSelectOrderBys(baseCommand.SqlOrders, orderReverse);

            if (baseCommand.PageSize > 0 && baseCommand.RecordStart <= 0)
            {
                sb.AppendSelectLimit(baseCommand.PageSize);
            }
            else if (baseCommand.PageSize > 0 && baseCommand.RecordStart > 0)
            {
                sb.AppendSelectLimit(baseCommand.RecordStart, baseCommand.PageSize);
            }

            return sb.ToString();
        }