ok-admin框架分页查询


效果图:

后台代码:

///


/// 分页数据
///

///
///
///
public string LoadPageList(int page, int limit,SysUser where)
{
//实例化数据库上下文
YuanGongDb dbcontext = new YuanGongDb();
List data = null;
Expression> wherelambad = u => 1 == 1;//查询条件;
if (where.username != null && where.username != "")
{
//Contains模糊查找
wherelambad = wherelambad = u => u.username.Contains(where.username);
}
if (where.Realname != null && where.Realname != "")
{
wherelambad = wherelambad = u => u.Realname==where.Realname;
}
int count = 0;
data = dbcontext.SysUser.Where(wherelambad).OrderBy(o => o.createtime)
.Skip((page - 1) * limit).Take(limit).ToList();
count = dbcontext.SysUser.Where(wherelambad).Count();
var result = new
{
code = 0,
count = count,
data = data,
msg = ""
};
return JsonConvert.SerializeObject(result);
}

前端代码:


@{
ViewBag.Title = "员工列表";
Layout = null;
}






员工列表



















@**@