コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }