zoukankan      html  css  js  c++  java
  • 分页的拼接字符串的方法

     /// <param name="tableName">table名称</param>
            /// <param name="keyFieldName">主键字段名称</param>
            /// <param name="currentPageIndex">当前页码</param>
            /// <param name="pageCount">每页显示记录数</param>
            /// <param name="conditionString">限制条件字符串</param>
            /// <returns></returns>
            protected virtual string GetExecutePageingSql(string tableName, string keyFieldName, int currentPageIndex, int pageCount, string conditionString)
            {
                if (string.IsNullOrEmpty(tableName))
                {
                    throw new ArgumentNullException("tableName");
                }

                if (string.IsNullOrEmpty(keyFieldName))
                {
                    throw new ArgumentNullException("keyFieldName");
                }

                if (currentPageIndex < 0)
                {
                    throw new ApplicationException(string.Format(@"currentPageIndex值为:{0},currentPageIndex必须大于等于1,该值不符合要求。", currentPageIndex));
                }

                if (pageCount < 1)
                {
                    throw new ApplicationException(string.Format(@"pageCount值为:{0},pageCount必须大于等于1,该值不符合要求。", pageCount));
                }

                StringBuilder stringBuilder = new StringBuilder();

                stringBuilder.AppendFormat(@"select top {0} * from {1} where {2} not in(select top {3} {2} from {1}  where 1=1 {4}) {4};select count(*) from {1} where 1=1 {4};",
                    pageCounts,
                    tableName,
                    keyFieldName,
                    pageCount * (currentPageIndex - 1),
                    conditionString);

                return Convert.ToString(stringBuilder);
            }

    1=1可以理解成and

  • 相关阅读:
    HDU 1423 Greatest Common Increasing Subsequence(LICS入门,只要求出最长数)
    HDU 5455 Fang Fang
    hihoCoder 1234 fractal
    二叉排序树
    最大连续子序列和,最大上升子序列和,最长上升子序列,最长公共子串,最长公共子序列,最长上升公共子序列
    C++ string string string string string string string string string string
    pip安装第三方库
    pip安装时使用国内源,加快下载速度
    pip升级命令
    instanceof -- JS
  • 原文地址:https://www.cnblogs.com/meroselove/p/2205413.html
Copyright © 2011-2022 走看看