public async Task <RestCollectionData> QueryDataAsync(IRestCollectionQuery query) { await _context.Repository.InitializeAsync(); var fieldAuth = new FieldAuthChecker <TItem>(_context.Fields, _context.AuthorizationChecker, null); IEnumerable <string> fields = fieldAuth.GetOrEnsureFields(query?.SelectFields, 1); var selector = new QueryableFieldSelector <TItem>(_context.Fields.GetReaders(fields)); var queryBuilder = new ContextQueryBuilder <TItem>(_context, query); IQueryable <TItem> items = queryBuilder.BuildQueryable(); QueriedDataIterator queriedData = await selector.SelectFieldsOnlyAsync(items, _context.Repository.ForEachAsync); PageDetails pageDetails = queryBuilder.GetPageDetails(queriedData); return(new RestCollectionData(queriedData, pageDetails)); }
public async Task <RestDictionaryData> QueryDataAsync(IRestCollectionQuery query) { await _context.Repository.InitializeAsync(); var queryBuilder = new ContextQueryBuilder <TItem>(_context, query); IQueryable <TItem> items = queryBuilder.BuildQueryable(); var fieldAuth = new FieldAuthChecker <TItem>(_context.Fields, _context.AuthorizationChecker, null); IEnumerable <string> fields = fieldAuth.GetOrEnsureFields(query?.SelectFields, 1); var readers = _context.Fields.GetReaders(fields); readers.Add(IDENTIFIER_FIELD_NAME, new IdentifierFieldReader <TItem>(_namedReferenceInfo)); var selector = new QueryableFieldSelector <TItem>(readers); QueriedDataIterator queriedData = await selector.SelectFieldsOnlyAsync(items, _context.Repository.ForEachAsync); PageDetails pageDetails = queryBuilder.GetPageDetails(queriedData); var dictionaryData = GetKeys(queriedData).ToDictionary(k => k.Key, v => (object)v.Value); return(new RestDictionaryData(dictionaryData, pageDetails)); }