Пример #1
0
        public virtual Task <IResourceCollectionDocument> GetRecords(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            var query           = _dbContext.Set <T>().AsQueryable();
            var sortExpressions = _sortExpressionExtractor.ExtractSortExpressions(request);

            return(_queryableResourceCollectionDocumentBuilder.BuildDocument(query, request, sortExpressions, cancellationToken));
        }
Пример #2
0
        public virtual Task <IResourceCollectionDocument> GetRecords(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            var sortExpressions = _sortExpressionExtractor.ExtractSortExpressions(request);
            var includes        = _includeExpressionExtractor.ExtractIncludeExpressions(request);
            var query           = QueryIncludeNavigationProperties(null, GetNavigationPropertiesIncludes <T>(includes));

            return(_queryableResourceCollectionDocumentBuilder.BuildDocument(query, request, sortExpressions, cancellationToken, includes));
        }
        public async Task <IJsonApiDocument> GetRelatedResourceDocument(string primaryResourceId, HttpRequestMessage request,
                                                                        CancellationToken cancellationToken)
        {
            var query = await GetRelatedQuery(primaryResourceId, cancellationToken);

            var includes        = GetIncludePaths();
            var sortExpressions = _sortExpressionExtractor.ExtractSortExpressions(request);

            if (sortExpressions == null || sortExpressions.Length < 1)
            {
                sortExpressions = GetDefaultSortExpressions();
            }
            return(await _queryableResourceCollectionDocumentBuilder.BuildDocument(query, request, sortExpressions, cancellationToken, includes)); // TODO: allow implementors to specify metadata
        }
        public virtual async Task <IResourceCollectionDocument> GetRecords(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            var entityQuery    = GetQuery();
            var includePaths   = GetIncludePathsForQuery() ?? new Expression <Func <TDto, object> >[] { };
            var jsonApiPaths   = includePaths.Select(ConvertToJsonKeyPath).ToArray();
            var mappedQuery    = GetMappedQuery(entityQuery, includePaths);
            var sortationPaths = _sortExpressionExtractor.ExtractSortExpressions(request);

            if (sortationPaths == null || !sortationPaths.Any())
            {
                sortationPaths = GetDefaultSortExpressions();
            }

            return(await _queryableResourceCollectionDocumentBuilder.BuildDocument(mappedQuery, request, sortationPaths, cancellationToken, jsonApiPaths));
        }