Beispiel #1
0
        public void Apply_AddsMapping()
        {
            _nodeWithResultSelector.Apply(QueryModel, ClauseGenerationContext);
            var clause = (AdditionalFromClause)QueryModel.BodyClauses[0];

            Assert.That(ClauseGenerationContext.GetContextInfo(_nodeWithResultSelector), Is.SameAs(clause));
        }
Beispiel #2
0
        public void Apply_AddsMapping()
        {
            _node.Apply(QueryModel, ClauseGenerationContext);
            var clause = (JoinClause)QueryModel.BodyClauses[0];

            Assert.That(ClauseGenerationContext.GetContextInfo(_node), Is.SameAs(clause));
        }
Beispiel #3
0
        public void Apply_AddsMapping()
        {
            _node.Apply(QueryModel, ClauseGenerationContext);

            var innerFetchRequest = ((FetchRequestBase)QueryModel.ResultOperators[0]).InnerFetchRequests.Single();

            Assert.That(ClauseGenerationContext.GetContextInfo(_node), Is.SameAs(innerFetchRequest));
        }
        public void Apply_AddsMapping()
        {
            _node.Apply(QueryModel, ClauseGenerationContext);

            var resultOperator = (ConcatResultOperator)QueryModel.ResultOperators[0];

            Assert.That(ClauseGenerationContext.GetContextInfo(_node), Is.SameAs(resultOperator));
        }
Beispiel #5
0
        public void Apply_AddsMapping()
        {
            _nodeWithElementSelector.Apply(QueryModel, ClauseGenerationContext);

            var resultOperator = (GroupResultOperator)QueryModel.ResultOperators[0];

            Assert.That(ClauseGenerationContext.GetContextInfo(_nodeWithElementSelector), Is.SameAs(resultOperator));
        }
Beispiel #6
0
        protected override void ApplyNodeSpecificSemantics(QueryModel queryModel, ClauseGenerationContext clauseGenerationContext)
        {
            var queryAnnotationResultOperator
                = (QueryAnnotationResultOperator)clauseGenerationContext.GetContextInfo(Source);

            ((IncludeQueryAnnotation)queryAnnotationResultOperator.Annotation)
            .AppendToNavigationPath(_navigationPropertyPathLambda.GetComplexPropertyAccess());

            clauseGenerationContext.AddContextInfo(this, queryAnnotationResultOperator);
        }
        protected override QueryModel ApplyNodeSpecificSemantics(QueryModel queryModel, ClauseGenerationContext clauseGenerationContext)
        {
            var includeResultOperator
                = (IncludeResultOperator)clauseGenerationContext.GetContextInfo(Source);

            includeResultOperator.AppendToNavigationPath(_navigationPropertyPathLambda.GetComplexPropertyAccess());

            clauseGenerationContext.AddContextInfo(this, includeResultOperator);

            return(queryModel);
        }
Beispiel #8
0
        public void Apply_AddsMappingForExisting()
        {
            _node.Apply(QueryModel, ClauseGenerationContext);

            var node = new ThenFetchOneExpressionNode(CreateParseInfo(_sourceFetchRequestNode), ExpressionHelper.CreateLambdaExpression <Cook, Cook> (s => s.Substitution));

            node.Apply(QueryModel, ClauseGenerationContext);

            var innerFetchRequest = ((FetchRequestBase)QueryModel.ResultOperators[0]).InnerFetchRequests.Single();

            Assert.That(ClauseGenerationContext.GetContextInfo(node), Is.SameAs(innerFetchRequest));
        }
Beispiel #9
0
        public void Apply_WithExistingFetchOneRequest()
        {
            var request = new FetchOneRequest(_node.RelationMember);

            QueryModel.ResultOperators.Add(request);

            _node.Apply(QueryModel, ClauseGenerationContext);

            Assert.That(QueryModel.ResultOperators.Count, Is.EqualTo(1));
            Assert.That(QueryModel.ResultOperators[0], Is.SameAs(request));
            Assert.That(ClauseGenerationContext.GetContextInfo(_node), Is.SameAs(QueryModel.ResultOperators[0]));
        }
        /// <summary>
        ///    Copy from EntityFramework Core source code. Modified to store predict expressions.
        /// </summary>
        protected override void ApplyNodeSpecificSemantics(QueryModel queryModel, ClauseGenerationContext clauseGenerationContext)
        {
            var includeResultOperator = (ReplaceIncludeResultOperator)clauseGenerationContext.GetContextInfo(Source);

            includeResultOperator.AppendToNavigationPath(GetComplexPropertyAccess(_navigationPropertyPathLambda));

            foreach (var expression in _expressions)
            {
                includeResultOperator.Expressions.Add(expression.Key, expression.Value);
            }

            clauseGenerationContext.AddContextInfo(this, includeResultOperator);
        }
        /// <summary>
        ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
        ///     directly from your code. This API may change or be removed in future releases.
        /// </summary>
        protected override void ApplyNodeSpecificSemantics(
            QueryModel queryModel, ClauseGenerationContext clauseGenerationContext)
        {
            var includeResultOperator
                = (IncludeResultOperator)clauseGenerationContext.GetContextInfo(Source);

            includeResultOperator
            .AppendToNavigationPath(
                NavigationPropertyPathLambda.GetComplexPropertyAccess(
                    nameof(EntityFrameworkQueryableExtensions.ThenInclude)));

            clauseGenerationContext.AddContextInfo(this, includeResultOperator);
        }
        protected override QueryModel ApplyNodeSpecificSemantics(QueryModel queryModel, ClauseGenerationContext clauseGenerationContext)
        {
            var previousFetchRequest = clauseGenerationContext.GetContextInfo(Source) as FetchRequestBase;

            if (previousFetchRequest == null)
            {
                throw new ParserException("ThenFetchMany must directly follow another Fetch request.");
            }

            FetchRequestBase innerFetchRequest = new FetchManyRequest(RelationMember);

            innerFetchRequest = previousFetchRequest.GetOrAddInnerFetchRequest(innerFetchRequest);
            clauseGenerationContext.AddContextInfo(this, innerFetchRequest);

            return(queryModel);
        }
        protected override void ApplyNodeSpecificSemantics(QueryModel queryModel, ClauseGenerationContext clauseGenerationContext)
        {
            ArgumentUtility.CheckNotNull("queryModel", queryModel);

            var previousFetchRequest = clauseGenerationContext.GetContextInfo(Source) as FetchRequestBase;

            if (previousFetchRequest == null)
            {
                throw new NotSupportedException("ThenFetchMany must directly follow another Fetch request.");
            }

            var innerFetchRequest = CreateFetchRequest();

            innerFetchRequest = previousFetchRequest.GetOrAddInnerFetchRequest(innerFetchRequest);
            // Store a mapping between this node and the innerFetchRequest so that a later ThenFetch... node may add its request to the innerFetchRequest.
            clauseGenerationContext.AddContextInfo(this, innerFetchRequest);
        }
        /// <summary>
        ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
        ///     directly from your code. This API may change or be removed in future releases.
        /// </summary>
        protected override void ApplyNodeSpecificSemantics(
            QueryModel queryModel, ClauseGenerationContext clauseGenerationContext)
        {
            var includeResultOperator
                = (IncludeResultOperator)clauseGenerationContext.GetContextInfo(Source);

            if (!NavigationPropertyPathLambda.TryGetComplexPropertyAccess(out var propertyPath))
            {
                throw new InvalidOperationException(
                          CoreStrings.InvalidIncludeLambdaExpression(
                              nameof(EntityFrameworkQueryableExtensions.ThenInclude),
                              NavigationPropertyPathLambda));
            }

            includeResultOperator.AppendToNavigationPath(propertyPath);

            clauseGenerationContext.AddContextInfo(this, includeResultOperator);
        }
        public void AddContextInfo()
        {
            _context.AddContextInfo(_node, _clause);

            Assert.That(_context.GetContextInfo(_node), Is.Not.Null);
        }