public PageList <User> UserPageList(int pageSize, int pageIndex, string userName) { //Expression<Func<User, bool>> expression = s => true; //if (!string.IsNullOrEmpty(userName)) //{ // expression = expression.And(s => s.UserName == userName); //} var res = _userRepositories.QuerySet().Where(s => true); if (!string.IsNullOrEmpty(userName)) { res = res.Where(s => s.UserName == userName); } return(res.OrderBy(s => s.UserName).PageList(pageIndex, pageSize)); }