public SelectManyExpressionNode(
            MethodCallExpressionParseInfo parseInfo, LambdaExpression collectionSelector, LambdaExpression resultSelector)
            : base(parseInfo)
        {
            ArgumentUtility.CheckNotNull("collectionSelector", collectionSelector);

            if (collectionSelector.Parameters.Count != 1)
            {
                throw new ArgumentException("Collection selector must have exactly one parameter.", "collectionSelector");
            }

            CollectionSelector = collectionSelector;

            if (resultSelector != null)
            {
                if (resultSelector.Parameters.Count != 2)
                {
                    throw new ArgumentException("Result selector must have exactly two parameters.", "resultSelector");
                }

                ResultSelector = resultSelector;
            }
            else
            {
                var parameter1 = Expression.Parameter(collectionSelector.Parameters[0].Type, collectionSelector.Parameters[0].Name);
                var itemType   = ReflectionUtility.GetItemTypeOfIEnumerable(CollectionSelector.Body.Type, "collectionSelector");
                var parameter2 = Expression.Parameter(itemType, parseInfo.AssociatedIdentifier);
                ResultSelector = Expression.Lambda(parameter2, parameter1, parameter2);
            }

            _cachedCollectionSelector = new ResolvedExpressionCache <Expression> (this);
            _cachedResultSelector     = new ResolvedExpressionCache <Expression> (this);
        }
Ejemplo n.º 2
0
        public JoinExpressionNode(
            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");
            }

            InnerSequence    = innerSequence;
            OuterKeySelector = outerKeySelector;
            InnerKeySelector = innerKeySelector;
            ResultSelector   = resultSelector;

            _cachedOuterKeySelector = new ResolvedExpressionCache <Expression> (this);
            _cachedInnerKeySelector = new ResolvedExpressionCache <Expression> (this);
            _cachedResultSelector   = new ResolvedExpressionCache <Expression> (this);
        }
Ejemplo n.º 3
0
        public AggregateFromSeedExpressionNode(
            MethodCallExpressionParseInfo parseInfo,
            Expression seed,
            LambdaExpression func,
            LambdaExpression optionalResultSelector)
            : base(parseInfo, null, null)
        {
            ArgumentUtility.CheckNotNull("seed", seed);
            ArgumentUtility.CheckNotNull("func", func);

            if (func.Parameters.Count != 2)
            {
                throw new ArgumentException("Func must have exactly two parameters.", "func");
            }

            if (optionalResultSelector != null && optionalResultSelector.Parameters.Count != 1)
            {
                throw new ArgumentException("Result selector must have exactly one parameter.", "optionalResultSelector");
            }

            _seed = seed;
            _func = func;
            _optionalResultSelector = optionalResultSelector;
            _cachedFunc             = new ResolvedExpressionCache <LambdaExpression> (this);
        }
Ejemplo n.º 4
0
        public GroupByExpressionNode(MethodCallExpressionParseInfo parseInfo, LambdaExpression keySelector, LambdaExpression optionalElementSelector)
            : base(parseInfo, null, null)
        {
            ArgumentUtility.CheckNotNull("keySelector", keySelector);

            if (keySelector.Parameters.Count != 1)
            {
                throw new ArgumentException("KeySelector must have exactly one parameter.", "keySelector");
            }

            if (optionalElementSelector != null && optionalElementSelector.Parameters.Count != 1)
            {
                throw new ArgumentException("ElementSelector must have exactly one parameter.", "optionalElementSelector");
            }

            KeySelector             = keySelector;
            OptionalElementSelector = optionalElementSelector;

            _cachedKeySelector = new ResolvedExpressionCache <Expression> (this);

            if (optionalElementSelector != null)
            {
                _cachedElementSelector = new ResolvedExpressionCache <Expression> (this);
            }
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
        public AllExpressionNode(MethodCallExpressionParseInfo parseInfo, LambdaExpression predicate)
            : base(parseInfo, null, null)
        {
            ArgumentUtility.CheckNotNull("predicate", predicate);

            Predicate        = predicate;
            _cachedPredicate = new ResolvedExpressionCache <Expression> (this);
        }
Ejemplo n.º 7
0
        public OrderByDescendingExpressionNode(MethodCallExpressionParseInfo parseInfo, LambdaExpression keySelector)
            : base(parseInfo)
        {
            if (keySelector.Parameters.Count != 1)
            {
                throw new ArgumentException("KeySelector must have exactly one parameter.", "keySelector");
            }

            KeySelector     = keySelector;
            _cachedSelector = new ResolvedExpressionCache <Expression>(this);
        }
Ejemplo n.º 8
0
        public SelectExpressionNode(MethodCallExpressionParseInfo parseInfo, LambdaExpression selector)
            : base(parseInfo)
        {
            if (selector.Parameters.Count != 1)
            {
                throw new ArgumentException("Selector must have exactly one parameter.", "selector");
            }

            Selector        = selector;
            _cachedSelector = new ResolvedExpressionCache <Expression>(this);
        }
Ejemplo n.º 9
0
        public AggregateExpressionNode(MethodCallExpressionParseInfo parseInfo, LambdaExpression func)
            : base(parseInfo, null, null)
        {
            if (func.Parameters.Count != 2)
            {
                throw new ArgumentException("Func must have exactly two parameters.", "func");
            }

            Func        = func;
            _cachedFunc = new ResolvedExpressionCache <LambdaExpression>(this);
        }
Ejemplo n.º 10
0
        public WhereExpressionNode(MethodCallExpressionParseInfo parseInfo, LambdaExpression predicate)
            : base(parseInfo)
        {
            if (predicate.Parameters.Count != 1)
            {
                throw new ArgumentException("Predicate must have exactly one parameter.", "predicate");
            }

            Predicate        = predicate;
            _cachedPredicate = new ResolvedExpressionCache <Expression>(this);
        }
Ejemplo n.º 11
0
        public ThenByExpressionNode(MethodCallExpressionParseInfo parseInfo, LambdaExpression keySelector)
            : base(parseInfo)
        {
            ArgumentUtility.CheckNotNull("keySelector", keySelector);

            if (keySelector.Parameters.Count != 1)
            {
                throw new ArgumentException("KeySelector must have exactly one parameter.", "keySelector");
            }

            KeySelector     = keySelector;
            _cachedSelector = new ResolvedExpressionCache <Expression> (this);
        }
Ejemplo n.º 12
0
 public AllExpressionNode(MethodCallExpressionParseInfo parseInfo, LambdaExpression predicate)
     : base(parseInfo, null, null)
 {
     Predicate        = predicate;
     _cachedPredicate = new ResolvedExpressionCache <Expression>(this);
 }