【积分系统】--Linq表达式实现分页

【前言】

   最近小编在项目中需要通过Linq表达式实现数据的查询,但是在界面显示的时候需要进行分页,接下来和大家分享一下,这个功能点是怎么实现的。

HTML

<table id="dg" class="easyui-datagrid"title="累积审核"  style="width:75%;height:500px;"url="/AccumulateEvaluation/LoadPage" data-options="singleSelect:true,pagination:true,fitColumns:true,sortName:'itemid',sortOrder:'desc'" > 
            <thead>
                <tr>
                    <th data-options="field:'departmentName'" style="width: 8px" align="center">上传的类型</th>
                    <th data-options="field:'accumulateStates'" style="text-align: right; width: 8px" align="center">处理结果</th>
                    <th data-options="field:'accumulateDescription'" style="width: 10px" align="center">描述</th>
                    <th data-options="field:'userName'" style="text-align: right; width: 10px" align="center">上传者</th>
                    <th data-options="field:'userID'" style="width: 10px" align="center" hidden>上传者ID</th>
                    <th data-options="field:'date'" style="width: 10px" align="center">上传时间</th>
                    
            </tr>
         </thead>
    </table>

D层

public List<accumulateModel>  LoadPage(int pageSize, int pageIndex,out int total)
       {           

           //查询总记录.ToList();
           total = DBcontext.t_accumulate.Count();

          //分页查询t_accumulate
           List<accumulateModel> accumulatelist = new List<accumulateModel>();

           accumulatelist = (from a in DBcontext.t_accumulate
                             join d in DBcontext.t_department on a.departmentID equals d.departmentID
                             join u in DBcontext.t_user on a.userID equals u.userID
                             where (a.accumulateStates.Contains("未审核"))
                             select new accumulateModel()
                             {
                                 accumulateDescription = a.accumulateDescription,
                                 accumulateStates = a.accumulateStates,
                                 departmentName = d.departmentName,
                                 userName = u.userName,
                                 userID=u.userID,
                                 date =a.date
                             }).OrderBy(p => p.date).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();
           return accumulatelist;

       }



评论 12
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值