예제 #1
0
 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>());
 }