示例#1
0
        private void CompleteInternal <T>(QueryResult queryResult, Action <int, T> addToResult)
        {
            queryResult.Results.BlittableValidation();

            if (NoTracking == false)
            {
                _session.RegisterIncludes(queryResult.Includes);
            }

            for (int i = 0; i < queryResult.Results.Length; i++)
            {
                var document = (BlittableJsonReaderObject)queryResult.Results[i];
                var metadata = document.GetMetadata();

                metadata.TryGetId(out var id);

                addToResult(i, Deserialize <T>(id, document, metadata, _fieldsToFetch, NoTracking, _session));
            }

            if (NoTracking == false)
            {
                _session.RegisterMissingIncludes(queryResult.Results, queryResult.Includes, queryResult.IncludedPaths);
                if (queryResult.CounterIncludes != null)
                {
                    _session.RegisterCounters(
                        queryResult.CounterIncludes,
                        queryResult.IncludedCounterNames);
                }
            }
        }
示例#2
0
        private void CompleteInternal <T>(QueryResult queryResult, Action <int, T> addToResult)
        {
            queryResult.Results.BlittableValidation();

            if (NoTracking == false)
            {
                _session.RegisterIncludes(queryResult.Includes);
            }

            for (int i = 0; i < queryResult.Results.Length; i++)
            {
                var document = (BlittableJsonReaderObject)queryResult.Results[i];
                BlittableJsonReaderObject metadata;

                try
                {
                    metadata = document.GetMetadata();
                }
                catch (InvalidOperationException)
                {
                    if (document.Count != _facetResultProperties.Length)
                    {
                        throw;
                    }

                    foreach (var prop in _facetResultProperties)
                    {
                        if (document.TryGetMember(prop.Name, out _) == false)
                        {
                            throw;
                        }
                    }

                    throw new InvalidOperationException("Raw query with aggregation by facet should be called by " +
                                                        $"{nameof(IRawDocumentQuery<T>.ExecuteAggregation)} or {nameof(IAsyncRawDocumentQuery<T>.ExecuteAggregationAsync)} method.");
                }

                metadata.TryGetId(out var id);

                addToResult(i, Deserialize <T>(id, document, metadata, _fieldsToFetch, NoTracking, _session, _isProjectInto));
            }

            if (NoTracking == false)
            {
                _session.RegisterMissingIncludes(queryResult.Results, queryResult.Includes, queryResult.IncludedPaths);
                if (queryResult.CounterIncludes != null)
                {
                    _session.RegisterCounters(
                        queryResult.CounterIncludes,
                        queryResult.IncludedCounterNames);
                }
            }
        }
示例#3
0
        public List <T> Complete <T>()
        {
            _session.AssertNotDisposed(); // ensure that the user didn't do an async query then closed the session early
            var queryResult = _currentQueryResults.CreateSnapshot();

            queryResult.Results.BlittableValidation();

            if (NoTracking == false)
            {
                _session.RegisterIncludes(queryResult.Includes);
            }

            var list = new List <T>();

            foreach (BlittableJsonReaderObject document in queryResult.Results)
            {
                var metadata = document.GetMetadata();

                metadata.TryGetId(out var id);

                list.Add(Deserialize <T>(id, document, metadata, _fieldsToFetch, NoTracking, _session));
            }

            if (NoTracking == false)
            {
                _session.RegisterMissingIncludes(queryResult.Results, queryResult.Includes, queryResult.IncludedPaths);
                if (queryResult.CounterIncludes != null)
                {
                    _session.RegisterCounters(
                        queryResult.CounterIncludes,
                        queryResult.IncludedCounterNames);
                }
            }

            return(list);
        }