public GroupJoinExpressionNode (
        MethodCallExpressionParseInfo parseInfo, 
        Expression innerSequence,
        LambdaExpression outerKeySelector,
        LambdaExpression innerKeySelector,
        LambdaExpression resultSelector)
        : base(parseInfo)
    {
      ArgumentUtility.CheckNotNull ("innerSequence", innerSequence);
      ArgumentUtility.CheckNotNull ("outerKeySelector", outerKeySelector);
      ArgumentUtility.CheckNotNull ("innerKeySelector", innerKeySelector);
      ArgumentUtility.CheckNotNull ("resultSelector", resultSelector);

      if (outerKeySelector.Parameters.Count != 1)
        throw new ArgumentException ("Outer key selector must have exactly one parameter.", "outerKeySelector");
      if (innerKeySelector.Parameters.Count != 1)
        throw new ArgumentException ("Inner key selector must have exactly one parameter.", "innerKeySelector");
      if (resultSelector.Parameters.Count != 2)
        throw new ArgumentException ("Result selector must have exactly two parameters.", "resultSelector");

      var joinResultSelector = Expression.Lambda (Expression.Constant (null), outerKeySelector.Parameters[0], innerKeySelector.Parameters[0]);
      JoinExpressionNode = new JoinExpressionNode (parseInfo, innerSequence, outerKeySelector, innerKeySelector, joinResultSelector);
      
      ResultSelector = resultSelector;
      _cachedResultSelector = new ResolvedExpressionCache<Expression> (this);
    }
Exemple #2
0
        public GroupJoinExpressionNode(
            MethodCallExpressionParseInfo parseInfo,
            Expression innerSequence,
            LambdaExpression outerKeySelector,
            LambdaExpression innerKeySelector,
            LambdaExpression resultSelector)
            : base(parseInfo)
        {
            ArgumentUtility.CheckNotNull("innerSequence", innerSequence);
            ArgumentUtility.CheckNotNull("outerKeySelector", outerKeySelector);
            ArgumentUtility.CheckNotNull("innerKeySelector", innerKeySelector);
            ArgumentUtility.CheckNotNull("resultSelector", resultSelector);

            if (outerKeySelector.Parameters.Count != 1)
            {
                throw new ArgumentException("Outer key selector must have exactly one parameter.", "outerKeySelector");
            }
            if (innerKeySelector.Parameters.Count != 1)
            {
                throw new ArgumentException("Inner key selector must have exactly one parameter.", "innerKeySelector");
            }
            if (resultSelector.Parameters.Count != 2)
            {
                throw new ArgumentException("Result selector must have exactly two parameters.", "resultSelector");
            }

            var joinResultSelector = Expression.Lambda(Expression.Constant(null), outerKeySelector.Parameters[0], innerKeySelector.Parameters[0]);

            JoinExpressionNode = new JoinExpressionNode(parseInfo, innerSequence, outerKeySelector, innerKeySelector, joinResultSelector);

            ResultSelector        = resultSelector;
            _cachedResultSelector = new ResolvedExpressionCache <Expression> (this);
        }
    public override void SetUp ()
    {
      base.SetUp ();

      _innerSequence = ExpressionHelper.CreateExpression();
      _outerKeySelector = ExpressionHelper.CreateLambdaExpression<string, string> (o => o.ToString ());
      _innerKeySelector = ExpressionHelper.CreateLambdaExpression<string, string> (i => i.ToString ());
      _resultSelector = ExpressionHelper.CreateLambdaExpression<string, string, string> ((o, i) => o.ToString () + i.ToString ());

      _node = new JoinExpressionNode (CreateParseInfo (SourceNode, "join"), _innerSequence, _outerKeySelector, _innerKeySelector, _resultSelector);
      _joinClause = ExpressionHelper.CreateJoinClause<Cook> ();
    }
Exemple #4
0
        protected override QueryModel ApplyNodeSpecificSemantics(QueryModel queryModel, ClauseGenerationContext clauseGenerationContext)
        {
            var joinClause      = JoinExpressionNode.CreateJoinClause(clauseGenerationContext);
            var groupJoinClause = new GroupJoinClause(ResultSelector.Parameters[1].Name, ResultSelector.Parameters[1].Type, joinClause);

            clauseGenerationContext.AddContextInfo(this, groupJoinClause);
            queryModel.BodyClauses.Add(groupJoinClause);

            var selectClause = queryModel.SelectClause;

            selectClause.Selector = GetResolvedResultSelector(clauseGenerationContext);

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

            var joinResultSelector = Expression.Lambda(Expression.Constant(null), _outerKeySelector.Parameters[0], _innerKeySelector.Parameters[0]);
            var joinParseInfo      = new MethodCallExpressionParseInfo(AssociatedIdentifier, Source, _parsedExpression);
            var joinExpressionNode = new JoinExpressionNode(joinParseInfo, _innerSequence, _outerKeySelector, _innerKeySelector, joinResultSelector);

            var joinClause      = joinExpressionNode.CreateJoinClause(clauseGenerationContext);
            var groupJoinClause = new GroupJoinClause(_resultSelector.Parameters[1].Name, _resultSelector.Parameters[1].Type, joinClause);

            clauseGenerationContext.AddContextInfo(this, groupJoinClause);
            queryModel.BodyClauses.Add(groupJoinClause);

            var selectClause = queryModel.SelectClause;

            selectClause.Selector = GetResolvedResultSelector(clauseGenerationContext);
        }