public PagerList<Resource> Query(ResourceQuery query)
 {
     if (string.IsNullOrWhiteSpace(query.Order))   //分页必须先进行排序
         query.Order = "Id desc";
     query.TotalCount = ResourceRepository.GetAll().Count();
     IQueryable<Resource> roles = GetQueryConditions(ResourceRepository.GetAll(), query)   //where查询条件必须放在排序和分页前,不然生成SQL有BUG
         .OrderByIfOrderNullOrEmpty(query.Order)
             .Skip(query.GetSkipCount())
             .Take(query.PageSize);
     var result = new PagerList<Resource>(query);
     result.AddRange(roles.ToList());
     return result;
 }
示例#2
0
 public ActionResult Query(ResourceQuery query)
 {
     SetPage(query);
     var result = _resourceService.Query(query).Convert(p => p.ToTreeGridVm());
     return ToDataTreeGridResult(result, false, result.TotalCount);
 }
示例#3
0
 public PagerList<ResourceDto> Query(ResourceQuery query)
 {
     return PagerList(query).Convert(p => p.MapTo<ResourceDto>());
 }
示例#4
0
 /// <summary>
 /// 构造前台传递的查询条件
 /// </summary>
 /// <param name="queryable"></param>
 /// <param name="query"></param>
 /// <returns></returns>
 private IQueryable<Resource> GetQueryConditions(IQueryable<Resource> queryable, ResourceQuery 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;
 }
示例#5
0
 public PagerList<ResourceDto> Query(ResourceQuery query, Guid roleId)
 {
     return PagerList(query).Convert(p => p.ToDto(roleId));
 }
示例#6
0
 public PagerList<ResourceDto> Query(ResourceQuery query, Guid roleId)
 {
     return _resourceDomainService.Query(query).Convert(p => p.ToDto(roleId));
 }
示例#7
0
 public PagerList<ResourceDto> Query(ResourceQuery query)
 {
     return _resourceDomainService.Query(query).Convert(p => p.MapTo<ResourceDto>());
 }