예제 #1
0
        public QueryingEnumerable(
            [NotNull] RelationalQueryContext relationalQueryContext,
            [NotNull] CommandBuilder commandBuilder,
            [NotNull] Func <DbDataReader, T> shaper,
            [NotNull] ILogger logger)
        {
            Check.NotNull(relationalQueryContext, nameof(relationalQueryContext));
            Check.NotNull(relationalQueryContext, nameof(relationalQueryContext));
            Check.NotNull(relationalQueryContext, nameof(relationalQueryContext));
            Check.NotNull(relationalQueryContext, nameof(relationalQueryContext));

            _relationalQueryContext = relationalQueryContext;
            _commandBuilder         = commandBuilder;
            _shaper = shaper;
            _logger = logger;
        }
예제 #2
0
        public AsyncQueryingEnumerable(
            [NotNull] RelationalQueryContext relationalQueryContext,
            [NotNull] CommandBuilder commandBuilder,
            [NotNull] Func <DbDataReader, T> shaper,
            [NotNull] ILogger logger)
        {
            Check.NotNull(relationalQueryContext, "relationalQueryContext");
            Check.NotNull(commandBuilder, "commandBuilder");
            Check.NotNull(shaper, "shaper");
            Check.NotNull(logger, "logger");

            _relationalQueryContext = relationalQueryContext;
            _commandBuilder         = commandBuilder;
            _shaper = shaper;
            _logger = logger;
        }
예제 #3
0
        private static IAsyncEnumerable <T> _Include <T>(
            RelationalQueryContext queryContext,
            IAsyncEnumerable <T> innerResults,
            IQuerySource querySource,
            IReadOnlyList <INavigation> navigationPath,
            IReadOnlyList <Func <IAsyncIncludeRelatedValuesStrategy> > includeRelatedValuesStrategyFactories)
            where T : QuerySourceScope
        {
            queryContext.BeginIncludeScope();

            var includeRelatedValuesStrategies
                = includeRelatedValuesStrategyFactories
                  .Select(f => f())
                  .ToList();

            var relatedValueReaders
                = includeRelatedValuesStrategies
                  .Select <
                      IAsyncIncludeRelatedValuesStrategy,
                      Func <EntityKey, Func <IValueReader, EntityKey>, IAsyncEnumerable <IValueReader> > >(
                      s => s.GetRelatedValues)
                  .ToArray();

            return
                (innerResults.Select(
                     async qss =>
            {
                await queryContext.QueryBuffer
                .IncludeAsync(
                    qss.GetResult(querySource),
                    navigationPath,
                    relatedValueReaders,
                    queryContext.CancellationToken);

                return qss;
            })
                 .Finally(() =>
            {
                foreach (var includeRelatedValuesStrategy in includeRelatedValuesStrategies)
                {
                    includeRelatedValuesStrategy.Dispose();
                }

                queryContext.EndIncludeScope();
            }));
        }
        private static IEnumerable <T> _Include <T>(
            RelationalQueryContext queryContext,
            IEnumerable <T> innerResults,
            IQuerySource querySource,
            IReadOnlyList <INavigation> navigationPath,
            IReadOnlyList <Func <IIncludeRelatedValuesStrategy> > includeRelatedValuesStrategyFactories,
            bool querySourceRequiresTracking)
            where T : QuerySourceScope
        {
            queryContext.BeginIncludeScope();

            var includeRelatedValuesStrategies
                = includeRelatedValuesStrategyFactories
                  .Select(f => f())
                  .ToList();

            var relatedEntitiesLoaders
                = includeRelatedValuesStrategies
                  .Select <IIncludeRelatedValuesStrategy, RelatedEntitiesLoader>(s => s.GetRelatedValues)
                  .ToArray();

            return(innerResults
                   .Select(qss =>
            {
                queryContext.QueryBuffer
                .Include(
                    qss.GetResult(querySource),
                    navigationPath,
                    relatedEntitiesLoaders,
                    querySourceRequiresTracking);

                return qss;
            })
                   .Finally(() =>
            {
                foreach (var includeRelatedValuesStrategy in includeRelatedValuesStrategies)
                {
                    includeRelatedValuesStrategy.Dispose();
                }

                queryContext.EndIncludeScope();
            }));
        }
예제 #5
0
 private static IAsyncIncludeRelatedValuesStrategy _CreateReferenceIncludeStrategy(
     RelationalQueryContext relationalQueryContext, int readerIndex, int readerOffset)
 {
     return(new ReferenceIncludeRelatedValuesStrategy(relationalQueryContext, readerIndex, readerOffset));
 }