码迷,mamicode.com
首页 > 其他好文 > 详细

加载分页

时间:2017-08-08 12:31:38      阅读:100      评论:0      收藏:0      [点我收藏+]

标签:bsp   set   turn   cut   ps1   range   ade   database   tab   

        public List<Customer> LoadPage(string where, int index, int size, out int total, List<DbParameter> args) {
            List<DbParameter> ps = new List<DbParameter>();
            ps.AddRange(args);

            string sql = @"SELECT COUNT(0) as total FROM [dbo].[Customer] WHERE [member_id] != ‘‘ " + where;
            total = Convert.ToInt32(database.ExecuteScalar(sql, ps));

            sql = @"
SELECT
    *
FROM
    [dbo].[Customer]
WHERE
    [member_id] != ‘‘
" + where + @"
ORDER BY ID DESC
OFFSET @p ROWS FETCH NEXT @pz ROWS ONLY";

            List<DbParameter> ps1 = new List<DbParameter>();
            ps1.AddRange(args);
            ps1.Add(new SqlParameter("@p", (index - 1) * size));
            ps1.Add(new SqlParameter("@pz", size));

            return database.ExecuteReader<Customer>(sql, ps1);
        }

加载分页

标签:bsp   set   turn   cut   ps1   range   ade   database   tab   

原文地址:http://www.cnblogs.com/xielideboke/p/7305956.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!