示例#1
0
        public QueryModel GetParsedQuery(Expression expressionTreeRoot)
        {
            Mandate.ParameterNotNull(expressionTreeRoot, "expressionTreeRoot");

            EnsureCustomModifiersRegisteredWithRelinq();

            return(ApplyAllNodes(_expressionTreeParser.ParseTree(expressionTreeRoot), new ClauseGenerationContext(_expressionTreeParser.NodeTypeProvider)));
        }
示例#2
0
        public void ParseTree_AppliesProcessingSteps()
        {
            var inputExpression = Expression.Constant(0);
            Expression <Func <int, bool> > predicate = i => i > 5;
            var transformedExpression = _intSource.Where(predicate).Expression;

            var stepMock1 = MockRepository.GenerateStrictMock <IExpressionTreeProcessor> ();

            stepMock1.Expect(mock => mock.Process(inputExpression)).Return(transformedExpression);
            stepMock1.Replay();


            var parser = new ExpressionTreeParser(_methodInfoBasedNodeTypeRegistry, stepMock1);

            var result = (WhereExpressionNode)parser.ParseTree(inputExpression);

            stepMock1.VerifyAllExpectations();
            Assert.That(result.Predicate, Is.SameAs(predicate));
        }
示例#3
0
        public void ParseTree_Expression()
        {
            var expression = Expression.MakeMemberAccess(new QuerySourceReferenceExpression(ExpressionHelper.CreateMainFromClause <Cook> ()), typeof(Cook).GetProperty("Assistants"));

            var result = _expressionTreeParser.ParseTree(expression);

            Assert.That(result, Is.InstanceOf(typeof(MainSourceExpressionNode)));
            Assert.That(((MainSourceExpressionNode)result).ParsedExpression, Is.SameAs(expression));
            Assert.That(((MainSourceExpressionNode)result).QuerySourceElementType, Is.SameAs(typeof(Cook)));
            Assert.That(((MainSourceExpressionNode)result).AssociatedIdentifier, Is.EqualTo("<generated>_0"));
        }