Пример #1
0
        /// <inheritdoc cref="IQueryBatchItem.ProcessResults" />
        public async Task ProcessResultsAsync(CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();
            ThrowIfNotInitialized();

            using (Session.SwitchCacheMode(_cacheMode))
                await(InitializeEntitiesAndCollectionsAsync(_reader, _hydratedObjects, cancellationToken)).ConfigureAwait(false);

            for (var i = 0; i < _queryInfos.Count; i++)
            {
                var queryInfo = _queryInfos[i];
                if (_subselectResultKeys[i] != null)
                {
                    queryInfo.Loader.CreateSubselects(_subselectResultKeys[i], queryInfo.Parameters, Session);
                }

                if (queryInfo.IsCacheable)
                {
                    if (queryInfo.IsResultFromCache)
                    {
                        var queryCacheBuilder = new QueryCacheResultBuilder(queryInfo.Loader);
                        queryInfo.Result = queryCacheBuilder.GetResultList(queryInfo.Result);
                    }

                    // This transformation must not be applied to ResultToCache.
                    queryInfo.Result =
                        queryInfo.Loader.TransformCacheableResults(
                            queryInfo.Parameters, queryInfo.CacheKey.ResultTransformer, queryInfo.Result);
                }
            }
            AfterLoadCallback?.Invoke(GetResults());
        }
        /// <inheritdoc cref="IQueryBatchItem.ProcessResults" />
        public void ProcessResults()
        {
            ThrowIfNotInitialized();

            using (Session.SwitchCacheMode(_cacheMode))
                InitializeEntitiesAndCollections(_reader, _hydratedObjects);

            for (var i = 0; i < _queryInfos.Count; i++)
            {
                var queryInfo = _queryInfos[i];
                if (_subselectResultKeys[i] != null)
                {
                    queryInfo.Loader.CreateSubselects(_subselectResultKeys[i], queryInfo.Parameters, Session);
                }

                if (queryInfo.IsCacheable)
                {
                    if (queryInfo.IsResultFromCache)
                    {
                        var queryCacheBuilder = new QueryCacheResultBuilder(queryInfo.Loader);
                        queryInfo.Result = queryCacheBuilder.GetResultList(queryInfo.Result);
                    }

                    // This transformation must not be applied to ResultToCache.
                    queryInfo.Result =
                        queryInfo.Loader.TransformCacheableResults(
                            queryInfo.Parameters, queryInfo.CacheKey.ResultTransformer, queryInfo.Result);
                }
            }
            AfterLoadCallback?.Invoke(GetResults());
        }