zoukankan      html  css  js  c++  java
  • Dapper的分页代码

            public KeyValuePair<Pagination, IList<AttachmentModel>> AttachmentPagination(Pagination pagin, AttachmentModel condition)
            {
                using (SqlConnection conn = DapperFactory.CrateOpenConnection())
                {
                    String executeQuery = @"WITH pagintable AS(
                                            SELECT ROW_NUMBER() OVER(ORDER BY CreateDate DESC )AS RowID, ID, FileID, TabName, TabID, FileName, FileDesc, FilePath, FileTypeID, FileSize, CreateDate, CreateMan, EditDate, EditMan, IsValid, NeedMoveToMoss, IsMoveToMoss, IsTemp,SequenceNum FROM Attachment
                                            WHERE 1= 1) 
                                            SELECT * FROM pagintable where RowID between ((@CurrentPageIndex - 1)  * @PageSize) + 1  and (@CurrentPageIndex  * @PageSize)";
                    String executeCount = "SELECT COUNT(*) AS CountNum FROM Attachment WHERE 1= 1";
                    var mixCondition = new
                    {
                        CurrentPageIndex = pagin.CurrentPageIndex,
                        PageSize = pagin.PageSize
                    };
                    List<AttachmentModel> listScore = conn.Query<AttachmentModel>(executeQuery, mixCondition).ToList();
                    pagin.TotalItemCount = conn.Query<Int32>(executeCount, mixCondition).SingleOrDefault<Int32>();
                    KeyValuePair<Pagination, IList<AttachmentModel>> result =
                        new KeyValuePair<Pagination, IList<AttachmentModel>>(pagin, listScore);
                    return result;
                }
            }
  • 相关阅读:
    静态方法
    表单的验证
    jquery笔记
    jquery参考
    dom体系 和获取其他页面的Window对象
    jsRegExp对象
    jsDate对象
    js案例
    Sqli-Labs 闯关 less 42-53
    Sqli-Labs 闯关 less 32-41
  • 原文地址:https://www.cnblogs.com/dongh/p/6603869.html
Copyright © 2011-2022 走看看