public Expression GetResolvedSelector(ClauseGenerationContext clauseGenerationContext) { return(_cachedSelector.GetOrCreate(r => { return r.GetResolvedExpression(Selector.Body, Expression.Parameter(typeof(int), ""), clauseGenerationContext); //return r.GetResolvedExpression(Selector.Body, Selector.Parameters[0], clauseGenerationContext); })); }
public Expression GetResolvedLetExpression(ClauseGenerationContext clauseGenerationContext) { if (!IsLetNode) { throw new InvalidOperationException("This node is not a 'let' node."); } return (_resolvedLetExpression.GetOrCreate( r => r.GetResolvedExpression(_letConstruction.Arguments[1], Selector.Parameters[0], clauseGenerationContext))); }
public Expression GetResolvedResultSelector(ClauseGenerationContext clauseGenerationContext) { return (_cachedResultSelector.GetOrCreate( r => r.GetResolvedExpression( QuerySourceExpressionNodeUtility.ReplaceParameterWithReference( this, ResultSelector.Parameters[1], ResultSelector.Body, clauseGenerationContext), ResultSelector.Parameters[0], clauseGenerationContext))); }
protected override ResultOperatorBase CreateResultOperator(ClauseGenerationContext clauseGenerationContext) { //Resolve identity expression (_=>_). Normally this would be resolved into QuerySourceReferenceExpression. var expression = _cache.GetOrCreate( r => r.GetResolvedExpression(Parameter, Parameter, clauseGenerationContext)); if (!(expression is QuerySourceReferenceExpression qsrExpression)) { throw new NotSupportedException($"WithLock is not supported on {expression}"); } return(new LockResultOperator(qsrExpression, _lockMode)); }
public Expression GetResolvedAdaptedSelector(ClauseGenerationContext clauseGenerationContext) { return(_resolvedAdaptedSelector.GetOrCreate( r => { var traversalDataType = typeof(TraversalData <,>).MakeGenericType(new Type[] { VertextType.Value as Type, EdgeType.Value as Type }); var constr = ReflectionUtils.GetConstructors(traversalDataType).ToList()[0]; var newExpression = Expression.Convert( Expression.New(constr), traversalDataType) ; return r.GetResolvedExpression(newExpression, Expression.Parameter(traversalDataType, "dummy"), clauseGenerationContext); })); }
public Expression GetResolvedAdaptedSelector(ClauseGenerationContext clauseGenerationContext) { return(_resolvedAdaptedSelector.GetOrCreate( r => { var groupingType = typeof(Grouping <,>).MakeGenericType(new Type[] { Selector.Body.Type, Selector.Parameters[0].Type }); var interface_groupingType = typeof(IGrouping <,>).MakeGenericType(new Type[] { Selector.Body.Type, Selector.Parameters[0].Type }); var constr = ReflectionUtils.GetConstructors(groupingType).ToList()[0]; var parameters = constr.GetParameters().Select(p => Expression.Parameter(p.ParameterType, p.Name)).ToArray(); var newExpression = Expression.Convert( Expression.New(constr, parameters , new MemberInfo[] { ReflectionUtils.GetMember(groupingType, "Key")[0] }) , interface_groupingType) ; return r.GetResolvedExpression(newExpression, Selector.Parameters[0], clauseGenerationContext); })); }
public Expression GetResolvedAdaptedSelector(ClauseGenerationContext clauseGenerationContext) { if (!IsLetNode) { throw new InvalidOperationException("This node is not a 'let' node."); } // Adapt the selector so that it contains a reference to the associated LetClause, i.e., instead of "x => new { x = x, y = expr }", // make it "x => new { x = x, y = [letClause] }" return(_resolvedAdaptedSelector.GetOrCreate( r => { var letClause = QuerySourceExpressionNodeUtility.GetQuerySourceForNode(this, clauseGenerationContext); var adaptedSelectorBody = Expression.New( _letConstruction.Constructor, new[] { _letConstruction.Arguments[0], new QuerySourceReferenceExpression(letClause) }, _letConstruction.Members); return r.GetResolvedExpression(adaptedSelectorBody, Selector.Parameters[0], clauseGenerationContext); })); }
public Expression GetResolvedResultSelector(ClauseGenerationContext clauseGenerationContext) { // our result selector usually looks like this: (i, j) => new { i = i, j = j } // with the data for i coming from the previous node and j identifying the data from this node // we resolve the selector by first substituting j by a QuerySourceReferenceExpression pointing back to us, before asking the previous node // to resolve i return(_cachedResultSelector.GetOrCreate( r => r.GetResolvedExpression( QuerySourceExpressionNodeUtility.ReplaceParameterWithReference (this, ResultSelector.Parameters[0], ResultSelector.Body, clauseGenerationContext), ResultSelector.Parameters[0], clauseGenerationContext))); // return _cachedResultSelector.GetOrCreate( //r => r.GetResolvedExpression( // QuerySourceExpressionNodeUtility.ReplaceParameterWithReference(this, ResultSelector.Parameters[1], ResultSelector.Body, clauseGenerationContext), // ResultSelector.Parameters[0], // clauseGenerationContext)); }
private Expression GetResolvedKeySelector(ClauseGenerationContext clauseGenerationContext) { return(_cachedSelector.GetOrCreate(r => r.GetResolvedExpression(_keySelector.Body, _keySelector.Parameters[0], clauseGenerationContext))); }
public Expression GetResolvedKeyPredicate(ClauseGenerationContext clauseGenerationContext) { return(_cachedKeySelector.GetOrCreate(r => r.GetResolvedExpression(KeySelector.Body, KeySelector.Parameters[0], clauseGenerationContext))); }
public Expression GetResolvedCollectionSelector(ClauseGenerationContext clauseGenerationContext) { return(_cachedCollectionSelector.GetOrCreate( r => r.GetResolvedExpression(CollectionSelector.Body, CollectionSelector.Parameters[0], clauseGenerationContext))); }
public Expression GetResolvedPredicate(ClauseGenerationContext clauseGenerationContext) { return(_cachedPredicate.GetOrCreate(r => r.GetResolvedExpression(_predicate.Body, _predicate.Parameters[0], clauseGenerationContext))); }
private Expression GetResolvedPredicate(ClauseGenerationContext context) => _resolvedPredicateCache.GetOrCreate( p => p.GetResolvedExpression(Predicate.Body, Predicate.Parameters[0], context));