Example #1
0
 /// <summary>
 /// 构造前台传递的查询条件
 /// </summary>
 /// <param name="queryable"></param>
 /// <param name="query"></param>
 /// <returns></returns>
 private IQueryable<User> GetQueryConditions(IQueryable<User> queryable, UserQuery query)
 {
     if (!string.IsNullOrWhiteSpace(query.Name))
         queryable = queryable.Where(p => p.Name.Contains(query.Name));
     if (query.Enabled != null)
         queryable = queryable.Where(p => p.Enabled == query.Enabled);
     return queryable;
 }
Example #2
0
 public PagerList<User> Query(UserQuery query)
 {
     if (string.IsNullOrWhiteSpace(query.Order))   //分页必须先进行排序
         query.Order = "Id desc";
     query.TotalCount = UserRepository.GetAllFilterDataPermissions().Count();
     IQueryable<User> users = GetQueryConditions(UserRepository.GetAllFilterDataPermissions(), query)   //where查询条件必须放在排序和分页前,不然生成SQL有BUG
         .OrderByIfOrderNullOrEmpty(query.Order)
             .Skip(query.GetSkipCount())
             .Take(query.PageSize);
     var result = new PagerList<User>(query);
     result.AddRange(users.ToList());
     return result;
 }
Example #3
0
 public PagerList<UserDto> Query(UserQuery query)
 {
     //todo:easyui组件的ajax请求异常,暂时无法拦截
     //throw new Exception("用户查询异常,easyui ajax操作全局异常测试");
     if (string.IsNullOrWhiteSpace(query.Order))   //分页必须先进行排序
         query.Order = "Id desc";
     query.TotalCount = _userRepository.GetAllFilterDataPermissions().Count();
     IQueryable<User> users = GetQueryConditions(_userRepository.GetAllFilterDataPermissions(), query)   //where查询条件必须放在排序和分页前,不然生成SQL有BUG
         .OrderByIfOrderNullOrEmpty(query.Order)
             .Skip(query.GetSkipCount())
             .Take(query.PageSize);
     var result = new PagerList<User>(query);
     result.AddRange(users.ToList());
     return result.Convert(p => p.ToDto());
 }
Example #4
0
 public ActionResult Query(UserQuery query)
 {
     SetPage(query);
     var result = _userService.Query(query).Convert(p => p.ToGridVm());
     return ToDataGridResult(result, result.TotalCount);
 }
Example #5
0
 public PagerList<UserDto> Query(UserQuery query)
 {
     //todo:easyui组件的ajax请求异常,暂时无法拦截
     //throw new Exception("用户查询异常,easyui ajax操作全局异常测试");
     return _userDomainService.Query(query).Convert(p => p.ToDto());
 }