• 分页的拼接字符串的方法


     /// <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

  • 相关阅读:
    MYSQL学习笔记
    javascript30--day01--Drum kit
    jQuery--dataTable 前端分页与后端分页 及遇到的问题
    hexo博客
    js—数组那些事儿
    累死青蛙系列——青蛙跳台阶问题
    js—求数组中的最大最小值
    前端html,css考点
    doxygen 使用 教程 不含安装仅设置
    fatal error LNK1169: one or more multiply defined symbols found 终极解决方案
  • 原文地址:https://www.cnblogs.com/meroselove/p/2205413.html
Copyright © 2020-2023  润新知