public LetSelectExpressionNode(MethodCallExpressionParseInfo parseInfo, LambdaExpression selector) : base(Utils.CheckNotNull("parseInfo", parseInfo), Utils.CheckNotNull("selector", selector)) { // Heuristically detect "let" constructs // Assume a Select call is a "let" construct if its selector looks like this: <x> => new { <x> = <x>, <y> = ... } var selectorBody = selector.Body as NewExpression; if (selectorBody != null && selectorBody.Arguments.Count == 2 && selectorBody.Arguments[0] == selector.Parameters[0] //&& selectorBody.Constructor.DeclaringType.IsDefined(typeof(CompilerGeneratedAttribute), false) && selectorBody.Members != null && selectorBody.Members.Count == 2) { _letConstruction = selectorBody; _resolvedAdaptedSelector = new ResolvedExpressionCache<Expression>(this); _resolvedLetExpression = new ResolvedExpressionCache<Expression>(this); } else { _letConstruction = null; _resolvedAdaptedSelector = null; _resolvedLetExpression = null; } }
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); }
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.GetItemTypeOfClosedGenericIEnumerable (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); }
public LetSelectExpressionNode(MethodCallExpressionParseInfo parseInfo, LambdaExpression selector) : base(LinqUtility.CheckNotNull("parseInfo", parseInfo), LinqUtility.CheckNotNull("selector", selector)) { // Heuristically detect "let" constructs // Assume a Select call is a "let" construct if its selector looks like this: <x> => new { <x> = <x>, <y> = ... } var selectorBody = selector.Body as NewExpression; if (selectorBody != null && selectorBody.Arguments.Count == 2 && selectorBody.Arguments[0] == selector.Parameters[0] //&& selectorBody.Constructor.DeclaringType.IsDefined(typeof(CompilerGeneratedAttribute), false) && selectorBody.Members != null && selectorBody.Members.Count == 2) { _letConstruction = selectorBody; _resolvedAdaptedSelector = new ResolvedExpressionCache <Expression>(this); _resolvedLetExpression = new ResolvedExpressionCache <Expression>(this); } else { _letConstruction = null; _resolvedAdaptedSelector = null; _resolvedLetExpression = null; } }
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 AllExpressionNode (MethodCallExpressionParseInfo parseInfo, LambdaExpression predicate) : base (parseInfo, null, null) { ArgumentUtility.CheckNotNull ("predicate", predicate); _predicate = predicate; _cachedPredicate = new ResolvedExpressionCache<Expression> (this); }
public WhereMissingExpressionNode(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); }
public LimitExpressionNode(MethodCallExpressionParseInfo parseInfo,ConstantExpression take, ConstantExpression skip) : base(parseInfo) { Utils.CheckNotNull("keySelector", take); Utils.CheckNotNull("keySelector", skip); Take = take; Skip = skip; _cachedSelector = new ResolvedExpressionCache<Expression>(this); }
public LimitExpressionNode(MethodCallExpressionParseInfo parseInfo, ConstantExpression take, ConstantExpression skip) : base(parseInfo) { Utils.CheckNotNull("keySelector", take); Utils.CheckNotNull("keySelector", skip); Take = take; Skip = skip; _cachedSelector = new ResolvedExpressionCache <Expression>(this); }
public AggregateExpressionNode (MethodCallExpressionParseInfo parseInfo, LambdaExpression func) : base(parseInfo, null, null) { ArgumentUtility.CheckNotNull ("func", func); if (func.Parameters.Count != 2) throw new ArgumentException ("Func must have exactly two parameters.", "func"); _func = func; _cachedFunc = new ResolvedExpressionCache<LambdaExpression> (this); }
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); }
public FilterExpressionNode(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); }
public OrderByComparerExpressionNode(MethodCallExpressionParseInfo parseInfo, LambdaExpression keySelector, ConstantExpression constantExpression) : base(parseInfo) { _keySelector = keySelector; _cachedSelector = new ResolvedExpressionCache <Expression>(this); _orderingDirection = parseInfo.ParsedExpression.Method.Name == nameof(Queryable.OrderBy) || parseInfo.ParsedExpression.Method.Name == nameof(Queryable.ThenBy) ? OrderingDirection.Asc : OrderingDirection.Desc; ConstantExpression = constantExpression; }
public InsertAndReturnExpressionNode(MethodCallExpressionParseInfo parseInfo, LambdaExpression withSelector , ConstantExpression collection) : base(parseInfo) { var withConstant = withSelector.Body as ConstantExpression; if (withConstant == null || withConstant.Value != null) { WithSelector = withSelector; _cachedWithSelector = new ResolvedExpressionCache<Expression>(this); } Collection = collection; }
public SelectExpressionNode(MethodCallExpressionParseInfo parseInfo, LambdaExpression selector) : base(parseInfo) { LinqUtility.CheckNotNull("selector", selector); if (selector.Parameters.Count != 1) { throw new ArgumentException("Selector must have exactly one parameter.", "selector"); } _selector = selector; _cachedSelector = new ResolvedExpressionCache <Expression>(this); }
public RemoveAndReturnExpressionNode(MethodCallExpressionParseInfo parseInfo, LambdaExpression keySelector ,ConstantExpression collection) : base(parseInfo) { var keyConstant = keySelector.Body as ConstantExpression; if (keyConstant == null || keyConstant.Value != null) { KeySelector = keySelector; _cachedKeySelector = new ResolvedExpressionCache<Expression>(this); } Collection = collection; }
public FetchExpressionNode(MethodCallExpressionParseInfo parseInfo, LambdaExpression selector) : base(parseInfo, null, null) { ArgumentUtility.CheckNotNull("selector", selector); if (selector.Parameters.Count != 1) { throw new ArgumentException("Selector must have exactly one parameter", "selector"); } Selector = selector; _cachedSelector = new ResolvedExpressionCache<Expression>(this); }
public TraversalExpressionNode(MethodCallExpressionParseInfo parseInfo, Expression startVertex) : base(parseInfo) { StartVertex = startVertex; identifier = Guid.NewGuid().ToString("N"); var genericTypes = parseInfo.ParsedExpression.Type.GenericTypeArguments[0].GenericTypeArguments; VertextType = Expression.Constant(genericTypes[0]); EdgeType = Expression.Constant(genericTypes[1]); _resolvedAdaptedSelector = new ResolvedExpressionCache <Expression>(this); }
public RemoveExpressionNode(MethodCallExpressionParseInfo parseInfo, LambdaExpression keySelector , ConstantExpression collection) : base(parseInfo) { var keyConstant = keySelector.Body as ConstantExpression; if (keyConstant == null || keyConstant.Value != null) { KeySelector = keySelector; _cachedKeySelector = new ResolvedExpressionCache <Expression>(this); } Collection = collection; }
public InsertExpressionNode(MethodCallExpressionParseInfo parseInfo, LambdaExpression withSelector , ConstantExpression collection) : base(parseInfo) { var withConstant = withSelector.Body as ConstantExpression; if (withConstant == null || withConstant.Value != null) { WithSelector = withSelector; _cachedWithSelector = new ResolvedExpressionCache <Expression>(this); } Collection = collection; }
public UpsertAndReturnExpressionNode(MethodCallExpressionParseInfo parseInfo, LambdaExpression searchSelector , LambdaExpression insertSelector, LambdaExpression updateSelector, ConstantExpression type) : base(parseInfo) { Utils.CheckNotNull("searchSelector", searchSelector); Utils.CheckNotNull("insertSelector", insertSelector); Utils.CheckNotNull("updateSelector", updateSelector); Utils.CheckNotNull("type", type); SearchSelector = searchSelector; InsertSelector = insertSelector; UpdateSelector = updateSelector; UpdateType = type; _cachedSearchSelector = new ResolvedExpressionCache<Expression>(this); _cachedInsertSelector = new ResolvedExpressionCache<Expression>(this); _cachedUpdateSelector = new ResolvedExpressionCache<Expression>(this); }
public LetLambdaExpressionNode( MethodCallExpressionParseInfo parseInfo, LambdaExpression letSelector, LambdaExpression collectionSelector) : base(parseInfo) { Utils.CheckNotNull("collectionSelector", collectionSelector); CollectionSelector = collectionSelector; LetSelector = letSelector; var parameter1 = Expression.Parameter(collectionSelector.Parameters[0].Type, collectionSelector.Parameters[0].Name); var itemType = CommonUtility.GetItemTypeOfClosedGenericIEnumerable(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); _cachedLetSelector = new ResolvedExpressionCache<Expression>(this); }
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); }
public UpsertExpressionNode(MethodCallExpressionParseInfo parseInfo, LambdaExpression searchSelector , LambdaExpression insertSelector, LambdaExpression updateSelector, ConstantExpression type) : base(parseInfo) { LinqUtility.CheckNotNull("searchSelector", searchSelector); LinqUtility.CheckNotNull("insertSelector", insertSelector); LinqUtility.CheckNotNull("updateSelector", updateSelector); LinqUtility.CheckNotNull("type", type); SearchSelector = searchSelector; InsertSelector = insertSelector; UpdateSelector = updateSelector; UpdateType = type; _cachedSearchSelector = new ResolvedExpressionCache <Expression>(this); _cachedInsertSelector = new ResolvedExpressionCache <Expression>(this); _cachedUpdateSelector = new ResolvedExpressionCache <Expression>(this); }
public LetLambdaExpressionNode( MethodCallExpressionParseInfo parseInfo, LambdaExpression letSelector, LambdaExpression collectionSelector) : base(parseInfo) { LinqUtility.CheckNotNull("collectionSelector", collectionSelector); CollectionSelector = collectionSelector; LetSelector = letSelector; var parameter1 = Expression.Parameter(collectionSelector.Parameters[0].Type, collectionSelector.Parameters[0].Name); var itemType = ReflectionUtils.GetItemTypeOfClosedGenericIEnumerable(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); _cachedLetSelector = new ResolvedExpressionCache <Expression>(this); }
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); }
public UpdateAndReturnExpressionNode(MethodCallExpressionParseInfo parseInfo, LambdaExpression withSelector , LambdaExpression keySelector,ConstantExpression command) : base(parseInfo) { Utils.CheckNotNull("withSelector", withSelector); if (withSelector.Parameters.Count != 1) throw new ArgumentException("Selector must have exactly one parameter.", "selector"); WithSelector = withSelector; _cachedWithSelector = new ResolvedExpressionCache<Expression>(this); var keyConstant = keySelector.Body as ConstantExpression; if (keyConstant ==null || keyConstant.Value != null) { KeySelector = keySelector; _cachedKeySelector = new ResolvedExpressionCache<Expression>(this); } Command = command; }
public NestExpressionNode(MethodCallExpressionParseInfo parseInfo, Expression innerSequence, LambdaExpression keySelector, LambdaExpression resultSelector) : base(parseInfo) { if (innerSequence == null) { throw new ArgumentNullException("innerSequence"); } if (keySelector == null) { throw new ArgumentNullException("keySelector"); } if (keySelector.Parameters.Count != 1) { throw new ArgumentException("Key selector must have exactly one parameter.", "keySelector"); } if (resultSelector == null) { throw new ArgumentNullException("resultSelector"); } if (resultSelector.Parameters.Count != 2) { throw new ArgumentException("Result selector must have exactly two parameters.", "resultSelector"); } InnerSequence = innerSequence; KeySelector = keySelector; ResultSelector = resultSelector; IsLeftOuterNest = parseInfo.ParsedExpression.Method.Name == "LeftOuterNest"; _cachedKeySelector = new ResolvedExpressionCache<Expression>(this); _cachedResultSelector = new ResolvedExpressionCache<Expression>(this); }
public NestExpressionNode(MethodCallExpressionParseInfo parseInfo, Expression innerSequence, LambdaExpression keySelector, LambdaExpression resultSelector) : base(parseInfo) { if (innerSequence == null) { throw new ArgumentNullException("innerSequence"); } if (keySelector == null) { throw new ArgumentNullException("keySelector"); } if (keySelector.Parameters.Count != 1) { throw new ArgumentException("Key selector must have exactly one parameter.", "keySelector"); } if (resultSelector == null) { throw new ArgumentNullException("resultSelector"); } if (resultSelector.Parameters.Count != 2) { throw new ArgumentException("Result selector must have exactly two parameters.", "resultSelector"); } InnerSequence = innerSequence; KeySelector = keySelector; ResultSelector = resultSelector; IsLeftOuterNest = parseInfo.ParsedExpression.Method.Name == "LeftOuterNest"; _cachedKeySelector = new ResolvedExpressionCache <Expression>(this); _cachedResultSelector = new ResolvedExpressionCache <Expression>(this); }
public UpdateAndReturnExpressionNode(MethodCallExpressionParseInfo parseInfo, LambdaExpression withSelector , LambdaExpression keySelector, ConstantExpression command) : base(parseInfo) { Utils.CheckNotNull("withSelector", withSelector); if (withSelector.Parameters.Count != 1) { throw new ArgumentException("Selector must have exactly one parameter.", "selector"); } WithSelector = withSelector; _cachedWithSelector = new ResolvedExpressionCache <Expression>(this); var keyConstant = keySelector.Body as ConstantExpression; if (keyConstant == null || keyConstant.Value != null) { KeySelector = keySelector; _cachedKeySelector = new ResolvedExpressionCache <Expression>(this); } Command = command; }
/// <summary> /// Creates a new AllAsyncExpressionNode. /// </summary> /// <param name="parseInfo">Method parse info.</param> /// <param name="predicate">Predicate which filters the results.</param> public AllAsyncExpressionNode(MethodCallExpressionParseInfo parseInfo, LambdaExpression predicate) : base(parseInfo, null, null) { Predicate = predicate ?? throw new ArgumentNullException(nameof(predicate)); _resolvedPredicateCache = new ResolvedExpressionCache <Expression>(this); }
public void SetUp() { var parseInfo = new MethodCallExpressionParseInfo("x", ExpressionNodeObjectMother.CreateMainSource(), ExpressionHelper.CreateMethodCallExpression <Cook>()); _cache = new ResolvedExpressionCache <Expression> (new TestMethodCallExpressionNode(parseInfo, null)); }
public LockExpressionNode(MethodCallExpressionParseInfo parseInfo, ConstantExpression lockMode) : base(parseInfo, null, null) { _lockMode = lockMode; _cache = new ResolvedExpressionCache <Expression>(this); }
public GroupByExpressionNode(MethodCallExpressionParseInfo parseInfo, LambdaExpression selector) : base(Utils.CheckNotNull("parseInfo", parseInfo), Utils.CheckNotNull("selector", selector)) { intoIdentifier = parseInfo.AssociatedIdentifier; _resolvedAdaptedSelector = new ResolvedExpressionCache<Expression>(this); }
public GroupByExpressionNode(MethodCallExpressionParseInfo parseInfo, LambdaExpression selector) : base(Utils.CheckNotNull("parseInfo", parseInfo), Utils.CheckNotNull("selector", selector)) { intoIdentifier = parseInfo.AssociatedIdentifier; _resolvedAdaptedSelector = new ResolvedExpressionCache <Expression>(this); }
public void SetUp () { var parseInfo = new MethodCallExpressionParseInfo("x", ExpressionNodeObjectMother.CreateMainSource(), ExpressionHelper.CreateMethodCallExpression<Cook>()); _cache = new ResolvedExpressionCache<Expression> (new TestMethodCallExpressionNode (parseInfo, null)); }