public List <ResourceEntity> GetPagedList(PagerRequest pagerRequest, out int totalCount, ResourceSortOrder sortOrder, SourceType?sourceType, int?sourceId) { List <int> list = null; if (sourceId != null) { list = new List <int>(1) { sourceId.Value }; } return(base.Get(Filter(DataStatus.Normal, sourceType, list), out totalCount, pagerRequest.PageIndex, pagerRequest.PageSize, GetOrder(sortOrder)).ToList()); }
/// <summary> /// 排序 /// </summary> /// <param name="sort"></param> /// <returns></returns> private static Func <IQueryable <ResourceEntity>, IOrderedQueryable <ResourceEntity> > GetOrder(ResourceSortOrder sort) { Func <IQueryable <ResourceEntity>, IOrderedQueryable <ResourceEntity> > order = null; switch (sort) { case ResourceSortOrder.CreateDate: order = v => v.OrderByDescending(s => s.CreatedDate); break; case ResourceSortOrder.Default: default: order = v => v.OrderBy(s => s.SourceType).ThenBy(s => s.SourceId).ThenBy(s => s.SortOrder); break; } return(order); }
public List <ResourceEntity> GetPagedList(PagerRequest pagerRequest, out int totalCount, ResourceSortOrder sortOrder) { return(base.Get(Filter(DataStatus.Normal, null, null), out totalCount, pagerRequest.PageIndex, pagerRequest.PageSize, GetOrder(sortOrder)).ToList()); }