protected override Expression VisitClientJoin(ClientJoinExpression join) { Expression expression = this.MakeJoinKey(join.InnerKey as IList <Expression>); Expression exp = this.MakeJoinKey(join.OuterKey as IList <Expression>); Expression projector = Expression.New(typeof(KeyValuePair <,>).MakeGenericType(new Type[] { expression.Type, join.Projection.Projector.Type }).GetConstructor(new Type[] { expression.Type, join.Projection.Projector.Type }), new Expression[] { expression, join.Projection.Projector }); ProjectionExpression projection = new ProjectionExpression(join.Projection.Select, projector); int num = ++this.nLookup; Expression expression5 = this.ExecuteProjection(projection, false); ParameterExpression expression6 = Expression.Parameter(projector.Type, "kvp"); if (join.Projection.Projector.NodeType == ((ExpressionType)0x3f9)) { LambdaExpression expression7 = Expression.Lambda(Expression.PropertyOrField(expression6, "Value").NotEqual(King.Framework.Linq.TypeHelper.GetNullConstant(join.Projection.Projector.Type)), new ParameterExpression[] { expression6 }); expression5 = Expression.Call(typeof(Enumerable), "Where", new Type[] { expression6.Type }, new Expression[] { expression5, expression7 }); } LambdaExpression expression8 = Expression.Lambda(Expression.PropertyOrField(expression6, "Key"), new ParameterExpression[] { expression6 }); LambdaExpression expression9 = Expression.Lambda(Expression.PropertyOrField(expression6, "Value"), new ParameterExpression[] { expression6 }); Expression item = Expression.Call(typeof(Enumerable), "ToLookup", new Type[] { expression6.Type, exp.Type, join.Projection.Projector.Type }, new Expression[] { expression5, expression8, expression9 }); ParameterExpression instance = Expression.Parameter(item.Type, "lookup" + num); Expression replaceWith = Expression.Call(instance, instance.Type.GetProperty("Item").GetGetMethod(), new Expression[] { this.Visit(exp) }); if (join.Projection.Aggregator != null) { replaceWith = DbExpressionReplacer.Replace(join.Projection.Aggregator.Body, join.Projection.Aggregator.Parameters[0], replaceWith); } this.variables.Add(instance); this.initializers.Add(item); return(replaceWith); }
protected ClientJoinExpression UpdateClientJoin(ClientJoinExpression join, ProjectionExpression projection, IEnumerable <Expression> outerKey, IEnumerable <Expression> innerKey) { if (((projection != join.Projection) || (outerKey != join.OuterKey)) || (innerKey != join.InnerKey)) { return(new ClientJoinExpression(projection, outerKey, innerKey)); } return(join); }
protected virtual Expression VisitClientJoin(ClientJoinExpression join) { ProjectionExpression projection = (ProjectionExpression)this.Visit(join.Projection); ReadOnlyCollection <Expression> outerKey = this.VisitExpressionList(join.OuterKey); ReadOnlyCollection <Expression> innerKey = this.VisitExpressionList(join.InnerKey); return(this.UpdateClientJoin(join, projection, outerKey, innerKey)); }
protected override Expression VisitClientJoin(ClientJoinExpression join) { ReadOnlyCollection <Expression> innerKey = this.VisitExpressionList(join.InnerKey); ReadOnlyCollection <Expression> outerKey = this.VisitExpressionList(join.OuterKey); ProjectionExpression projection = (ProjectionExpression)this.Visit(join.Projection); if (((projection != join.Projection) || (innerKey != join.InnerKey)) || (outerKey != join.OuterKey)) { return(new ClientJoinExpression(projection, outerKey, innerKey)); } return(join); }
protected override Expression VisitClientJoin(ClientJoinExpression join) { bool isTopLevel = this.isTopLevel; SelectExpression currentSelect = this.currentSelect; this.isTopLevel = true; this.currentSelect = null; Expression expression2 = base.VisitClientJoin(join); this.isTopLevel = isTopLevel; this.currentSelect = currentSelect; return(expression2); }
protected virtual Expression VisitClientJoin(ClientJoinExpression join) { this.AddAlias(join.Projection.Select.Alias); base.Write("ClientJoin("); base.WriteLine(ExpressionWriter.Indentation.Inner); base.Write("OuterKey("); this.VisitExpressionList(join.OuterKey); base.Write("),"); base.WriteLine(ExpressionWriter.Indentation.Same); base.Write("InnerKey("); this.VisitExpressionList(join.InnerKey); base.Write("),"); base.WriteLine(ExpressionWriter.Indentation.Same); this.Visit(join.Projection); base.WriteLine(ExpressionWriter.Indentation.Outer); base.Write(")"); return(join); }