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; }
public ActionResult Query(ResourceQuery query) { SetPage(query); var result = _resourceService.Query(query).Convert(p => p.ToTreeGridVm()); return ToDataTreeGridResult(result, false, result.TotalCount); }
public PagerList<ResourceDto> Query(ResourceQuery query) { return PagerList(query).Convert(p => p.MapTo<ResourceDto>()); }
/// <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; }
public PagerList<ResourceDto> Query(ResourceQuery query, Guid roleId) { return PagerList(query).Convert(p => p.ToDto(roleId)); }
public PagerList<ResourceDto> Query(ResourceQuery query, Guid roleId) { return _resourceDomainService.Query(query).Convert(p => p.ToDto(roleId)); }
public PagerList<ResourceDto> Query(ResourceQuery query) { return _resourceDomainService.Query(query).Convert(p => p.MapTo<ResourceDto>()); }