public PageList <T> GetEntities <T>(Expression <Func <T, bool> > query = null, ResourceCollectionParameters resourceCollectionParameters = null) { var(pageIdx, pageSize) = resourceCollectionParameters.GetPaginationTuple(); var entities = GetQueryableEntities <T>(); var result = query == null ? PageList <T> .Create(entities, pageIdx, pageSize) : PageList <T> .Create(entities.Where(query), pageIdx, pageSize); return(result); }
public async Task <PageList <HmmNote> > GetEntitiesAsync(Expression <Func <HmmNote, bool> > query = null, ResourceCollectionParameters resourceCollectionParameters = null) { var(pageIdx, pageSize) = resourceCollectionParameters.GetPaginationTuple(); var notes = query == null ? DataContext.Notes.Include(n => n.Author).Include(n => n.Catalog) : DataContext.Notes.Include(n => n.Author).Include(n => n.Catalog).Where(query); var result = resourceCollectionParameters == null ? await PageList <HmmNote> .CreateAsync(notes, pageIdx, pageSize) : await PageList <HmmNote> .CreateAsync(notes.ApplySort(resourceCollectionParameters.OrderBy), pageIdx, pageSize); return(result); }