当前位置: 首页>>代码示例>>C#>>正文


C# SelectCommand.InternalGetHavingCondition方法代码示例

本文整理汇总了C#中SelectCommand.InternalGetHavingCondition方法的典型用法代码示例。如果您正苦于以下问题:C# SelectCommand.InternalGetHavingCondition方法的具体用法?C# SelectCommand.InternalGetHavingCondition怎么用?C# SelectCommand.InternalGetHavingCondition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SelectCommand的用法示例。


在下文中一共展示了SelectCommand.InternalGetHavingCondition方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InternalGetPagerCommand

        /// <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();

            if (baseCommand.PageSize > 0 && baseCommand.RecordStart > 0)//分页模式
            {
                /*
                    SELECT * FROM
                    (
                        SELECT TOP 30 *, ROW_NUMBER() OVER(ORDER BY ID ASC) AS RN
                        FROM TABLE_NAME
                    ) AS T
                    WHERE RN > 20
                */

                sb.AppendSelectDistinct(baseCommand.UseDistinct).AppendAllColumnNames(baseCommand.UseDistinct, baseCommand.InternalGetQueryFieldList());

                SqlCommandBuilder innerBuilder = new SqlCommandBuilder(baseCommand.Database);
                innerBuilder.AppendSelectOrderBys(baseCommand.InternalGetOrderList(), false);

                SelectCommand innerCommand = baseCommand.Database.InternalCreateSelectCommand(baseCommand, baseCommand.TableName);
                innerCommand.InternalQuerys(baseCommand.QueryFields);
                innerCommand.InternalQuerys(SqlQueryField.InternalCreateFromFunction(baseCommand, "ROW_NUMBER() OVER( " + innerBuilder.ToString() + ")", "RN"));
                innerCommand.PageSize = baseCommand.RecordStart + baseCommand.PageSize;
                innerCommand.InternalSetJoinList(baseCommand);
                innerCommand.InternalSetWhereCondition(baseCommand);
                innerCommand.InternalSetGroupByFieldList(baseCommand);
                innerCommand.InternalSetHavingCondition(baseCommand);

                sb.AppendSelectFrom(innerCommand.GetCommandText("T"), true);
                sb.AppendWhere(baseCommand.ConditionBuilder.GreaterThanColumn("RN", baseCommand.RecordStart.ToString()));
            }
            else//正常模式
            {
                if (baseCommand.PageSize > 0)
                {
                    sb.AppendSelectTop(baseCommand.PageSize);
                }

                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);
            }

            return sb.ToString();
        }
开发者ID:svcdn,项目名称:DotMaysWind.Data,代码行数:57,代码来源:SqlServerSelectPager.cs

示例2: InternalGetPagerCommand

        /// <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();
        }
开发者ID:svcdn,项目名称:DotMaysWind.Data,代码行数:30,代码来源:MySQLSelectPager.cs

示例3: InternalGetPagerCommand

        /// <summary>
        /// 获取选择语句内容
        /// </summary>
        /// <param name="baseCommand">源选择语句</param>
        /// <param name="recordCount">记录数量</param>
        /// <param name="orderReverse">是否反转排序</param>
        /// <returns>选择语句内容</returns>
        internal static String InternalGetPagerCommand(SelectCommand baseCommand, Int32 recordCount, Boolean orderReverse)
        {
            SqlCommandBuilder sb = new SqlCommandBuilder(baseCommand.Database);
            sb.AppendSelectPrefix();

            if (baseCommand.PageSize > 0 && baseCommand.RecordStart > 0)//分页模式
            {
                Int32 realPageCount = (recordCount + baseCommand.PageSize - 1) / baseCommand.PageSize;
                Int32 realPageIndex = (baseCommand.RecordStart / baseCommand.PageSize) + 1;

                if (realPageIndex >= realPageCount)//最后一页
                {
                    sb.AppendSelectDistinct(baseCommand.UseDistinct).AppendAllColumnNames(baseCommand.UseDistinct, baseCommand.InternalGetQueryFieldList());

                    SelectCommand innerCommand = baseCommand.Database.InternalCreateSelectCommand(baseCommand, baseCommand.TableName);
                    innerCommand.PageSize = recordCount - baseCommand.RecordStart;
                    innerCommand.InternalSetQueryFieldList(baseCommand);
                    innerCommand.InternalSetJoinList(baseCommand);
                    innerCommand.InternalSetWhereCondition(baseCommand);
                    innerCommand.InternalSetGroupByFieldList(baseCommand);
                    innerCommand.InternalSetHavingCondition(baseCommand);
                    innerCommand.InternalSetOrderList(baseCommand);

                    sb.AppendSelectFrom(innerCommand.GetCommandText("T", !orderReverse), true);
                    sb.AppendSelectOrderBys(baseCommand.InternalGetOrderList(), orderReverse);
                }
                else if (realPageIndex < (realPageCount / 2 + realPageCount % 2))//前1/2部分页
                {
                    /*
                        SELECT * FROM
                        (
                            SELECT TOP 10 * FROM
                            (
                                SELECT TOP 30 * 
                                FROM TABLE_NAME
                                ORDER BY ID ASC
                            ) AS T1
                            ORDER BY ID DESC
                        ) AS T2
                        ORDER BY ID ASC
                    */

                    sb.AppendSelectDistinct(baseCommand.UseDistinct).AppendAllColumnNames(baseCommand.UseDistinct, baseCommand.InternalGetQueryFieldList());

                    SelectCommand innestCommand = baseCommand.Database.InternalCreateSelectCommand(baseCommand, baseCommand.TableName);
                    innestCommand.PageSize = baseCommand.RecordStart + baseCommand.PageSize;
                    innestCommand.InternalSetQueryFieldList(baseCommand);
                    innestCommand.InternalSetJoinList(baseCommand);
                    innestCommand.InternalSetWhereCondition(baseCommand);
                    innestCommand.InternalSetGroupByFieldList(baseCommand);
                    innestCommand.InternalSetHavingCondition(baseCommand);
                    innestCommand.InternalSetOrderList(baseCommand);

                    SelectCommand innerCommand = baseCommand.Database.InternalCreateSelectCommand(baseCommand, innestCommand, "T1");
                    innerCommand.PageSize = baseCommand.PageSize;
                    innerCommand.InternalSetQueryFieldList(baseCommand);
                    innerCommand.InternalSetOrderList(baseCommand);

                    sb.AppendSelectFrom(innerCommand.GetCommandText("T2", !orderReverse), true);
                    sb.AppendSelectOrderBys(baseCommand.InternalGetOrderList(), orderReverse);
                }
                else//后1/2部分页
                {
                    sb.AppendSelectTop(baseCommand.PageSize);
                    sb.AppendSelectDistinct(baseCommand.UseDistinct).AppendAllColumnNames(baseCommand.UseDistinct, baseCommand.InternalGetQueryFieldList());

                    SelectCommand innerCommand = baseCommand.Database.InternalCreateSelectCommand(baseCommand, baseCommand.TableName);
                    innerCommand.PageSize = recordCount - baseCommand.RecordStart;
                    innerCommand.InternalSetQueryFieldList(baseCommand);
                    innerCommand.InternalSetJoinList(baseCommand);
                    innerCommand.InternalSetWhereCondition(baseCommand);
                    innerCommand.InternalSetGroupByFieldList(baseCommand);
                    innerCommand.InternalSetHavingCondition(baseCommand);
                    innerCommand.InternalSetOrderList(baseCommand);

                    sb.AppendSelectFrom(innerCommand.GetCommandText("T", !orderReverse), true);
                    sb.AppendSelectOrderBys(baseCommand.InternalGetOrderList(), orderReverse);
                }
            }
            else//正常模式
            {
                if (baseCommand.PageSize > 0)
                {
                    sb.AppendSelectTop(baseCommand.PageSize);
                }

                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);
//.........这里部分代码省略.........
开发者ID:svcdn,项目名称:DotMaysWind.Data,代码行数:101,代码来源:AccessSelectPager.cs

示例4: InternalGetCountCommand

        /// <summary>
        /// 获取选择数量语句
        /// </summary>
        /// <param name="baseCommand">源选择语句</param>
        /// <returns>选择数量语句</returns>
        internal static String InternalGetCountCommand(SelectCommand baseCommand)
        {
            SqlCommandBuilder sb = new SqlCommandBuilder(baseCommand.Database);

            List<SqlQueryField> queryFields = new List<SqlQueryField>();
            queryFields.Add(SqlQueryField.InternalCreateFromAggregateFunction(baseCommand, SqlAggregateFunction.Count));

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

            sb.AppendWhere(baseCommand.WhereCondition);
            sb.AppendSelectGroupBys(baseCommand.InternalGetGroupByFieldList());
            sb.AppendHaving(baseCommand.InternalGetHavingCondition());

            return sb.ToString();
        }
开发者ID:svcdn,项目名称:DotMaysWind.Data,代码行数:22,代码来源:AccessSelectPager.cs

示例5: InternalGetSelectNoneCommand

        /// <summary>
        /// 获取选择空内容语句
        /// </summary>
        /// <param name="baseCommand">源选择语句</param>
        /// <param name="orderReverse">是否反转排序</param>
        /// <returns>选择空内容语句</returns>
        internal static String InternalGetSelectNoneCommand(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());

            if (baseCommand.WhereCondition != null)
            {
                sb.AppendWhere(baseCommand.ConditionBuilder.And(baseCommand.ConditionBuilder.False(), baseCommand.WhereCondition));
            }
            else
            {
                sb.AppendWhere(baseCommand.ConditionBuilder.False());
            }

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

            return sb.ToString();
        }
开发者ID:svcdn,项目名称:DotMaysWind.Data,代码行数:29,代码来源:AccessSelectPager.cs


注:本文中的SelectCommand.InternalGetHavingCondition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。