运用页面模型对SQL语句进行分页控制

searchcondition.cs

     /// <summary>
        /// 搜索控制
        /// </summary>
        public class SearchCondition
        {
            /// <summary>
            /// 条件字段
            /// </summary>
            public string ConditionField { get; set; }
            /// <summary>
            /// 搜索类型,1-等于;0-不等于;2-大于;3-小于;4-like;6-大于等于;7-小于等于; 8-in;9-not in;10-拼接;11-is null;12-is not null;
            /// </summary>
            public int SearchType { get; set; }

            /// <summary>
            /// 值
            /// </summary>
            public string ConditionValue { get; set; }

        }

    /// <summary>
   /// 搜索类型枚举
    /// </summary>
    public enum SearchTypeEnum : byte
    {
        等于=1,
        不等于=0,
        大于=2,
        小于=3,
        LIKE=4,
        大于等于=6,
        小于等于=7, 
        IN=8,
        notIN=9,
        拼接=10,
        isNULL=11,
        isnotNULL=12
    }

updatecondition.cs

   /// <summary>
    /// 更新控制
    /// </summary>
    public class UpdateCondition
    {
        /// <summary>
        /// 条件字段
        /// </summary>
        public string ConditionField { get; set; }

        /// <summary>
        /// 值
        /// </summary>
        public string ConditionValue { get; set; }
    }

ordermodel.cs

  /// <summary>
    /// 排序控制
    /// </summary>
    public class OrderModel
    {
        /// <summary>
        /// 排序字段
        /// </summary>
        public string FieldName { get; set; }
        /// <summary>
        /// 是不是降序
        /// </summary>
        public bool IsDesc { get; set; }
    }

pagemodel.cs

 /// <summary>
    /// 页面模型
    /// </summary>
    public class PageModel
    {
        /// <summary>
        /// 当前页号
        /// </summary>
        public int CurrentPage { get; set; }
        /// <summary>
        /// 总条数
        /// </summary>
        public int DataCount { get; set; }
        /// <summary>
        /// 每页条数
        /// </summary>
        public int PageSize { get; set; }
        /// <summary>
        /// 最大页数
        /// </summary>
        public int MaxPage { get; set; }
        /// <summary>
        ///SQL语句中 where条件集合
        /// </summary>
        public List<SearchCondition> TheSearchConditions = new List<SearchCondition>();
        /// <summary>
        ///SQL语句中 order by 条件集合
        /// </summary>
        public List<OrderModel> TheOrderModels = new List<OrderModel>();
        /// <summary>
        /// 获取最大页数
        /// </summary>
        public void GetMaxPage()
        {
            if (this.DataCount % this.PageSize == 0)
            {
                this.MaxPage = this.DataCount / this.PageSize;
            }
            else
            {
                this.MaxPage = this.DataCount / this.PageSize + 1;
            }
            if (this.MaxPage < 1)
            {
                this.MaxPage = 1;
            }
        }
    }
展开阅读全文
©️2020 CSDN 皮肤主题: 深蓝海洋 设计师: CSDN官方博客 返回首页
实付0元
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值