public virtual void VisitQueryJoinClause(QueryJoinClause queryJoinClause) { if (this.ThrowException) { throw (System.Exception) this.CreateException(queryJoinClause); } }
public virtual void VisitQueryJoinClause(QueryJoinClause queryJoinClause) { if (ThrowException) { throw (Exception)CreateException(queryJoinClause); } }
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) { QueryJoinClause o = other as QueryJoinClause; return(o != null && this.IsGroupJoin == o.IsGroupJoin && this.Type.DoMatch(o.Type, match) && MatchString(this.JoinIdentifier, o.JoinIdentifier) && this.InExpression.DoMatch(o.InExpression, match) && this.OnExpression.DoMatch(o.OnExpression, match) && this.EqualsExpression.DoMatch(o.EqualsExpression, match) && MatchString(this.IntoIdentifier, o.IntoIdentifier)); }
/// <inheritdoc/> public virtual void VisitQueryJoinClause(QueryJoinClause syntax) { VisitNode(syntax); }
public override void VisitQueryJoinClause(QueryJoinClause queryJoinClause) { throw NotSupportedToConsistency(); }
public RedILNode VisitQueryJoinClause(QueryJoinClause queryJoinClause, State data) { throw new System.NotImplementedException(); }
public void VisitQueryJoinClause(QueryJoinClause node) { NotSupported(node); }
QueryExpression DecompileQuery(InvocationExpression invocation) { if (invocation == null) { return(null); } if (invocation.Parent is ParenthesizedExpression == false && invocation.Parent is QueryClause == false) { return(null); } MemberReferenceExpression mre = invocation.Target as MemberReferenceExpression; if (mre == null) { return(null); } switch (mre.MemberName) { case "Select": { if (invocation.Arguments.Count != 1) { return(null); } string parameterName; Expression body; if (MatchSimpleLambda(invocation.Arguments.Single(), out parameterName, out body)) { QueryExpression query = new QueryExpression(); query.Clauses.Add(new QueryFromClause { Identifier = parameterName, Expression = Detach(mre.Target) }); query.Clauses.Add(new QuerySelectClause { Expression = Detach(body) }); return(query); } return(null); } case "GroupBy": { if (invocation.Arguments.Count == 2) { string parameterName1, parameterName2; Expression keySelector, elementSelector; if (MatchSimpleLambda(invocation.Arguments.ElementAt(0), out parameterName1, out keySelector) && MatchSimpleLambda(invocation.Arguments.ElementAt(1), out parameterName2, out elementSelector) && parameterName1 == parameterName2) { QueryExpression query = new QueryExpression(); query.Clauses.Add(new QueryFromClause { Identifier = parameterName1, Expression = Detach(mre.Target) }); query.Clauses.Add(new QueryGroupClause { Projection = Detach(elementSelector), Key = Detach(keySelector) }); return(query); } } else if (invocation.Arguments.Count == 1) { string parameterName; Expression keySelector; if (MatchSimpleLambda(invocation.Arguments.Single(), out parameterName, out keySelector)) { QueryExpression query = new QueryExpression(); query.Clauses.Add(new QueryFromClause { Identifier = parameterName, Expression = Detach(mre.Target) }); query.Clauses.Add(new QueryGroupClause { Projection = new IdentifierExpression(parameterName), Key = Detach(keySelector) }); return(query); } } return(null); } case "SelectMany": { if (invocation.Arguments.Count != 2) { return(null); } string parameterName; Expression collectionSelector; if (!MatchSimpleLambda(invocation.Arguments.ElementAt(0), out parameterName, out collectionSelector)) { return(null); } LambdaExpression lambda = invocation.Arguments.ElementAt(1) as LambdaExpression; if (lambda != null && lambda.Parameters.Count == 2 && lambda.Body is Expression) { ParameterDeclaration p1 = lambda.Parameters.ElementAt(0); ParameterDeclaration p2 = lambda.Parameters.ElementAt(1); if (p1.Name == parameterName) { QueryExpression query = new QueryExpression(); query.Clauses.Add(new QueryFromClause { Identifier = p1.Name, Expression = Detach(mre.Target) }); query.Clauses.Add(new QueryFromClause { Identifier = p2.Name, Expression = Detach(collectionSelector) }); query.Clauses.Add(new QuerySelectClause { Expression = Detach(((Expression)lambda.Body)) }); return(query); } } return(null); } case "Where": { if (invocation.Arguments.Count != 1) { return(null); } string parameterName; Expression body; if (MatchSimpleLambda(invocation.Arguments.Single(), out parameterName, out body)) { QueryExpression query = new QueryExpression(); query.Clauses.Add(new QueryFromClause { Identifier = parameterName, Expression = Detach(mre.Target) }); query.Clauses.Add(new QueryWhereClause { Condition = Detach(body) }); return(query); } return(null); } case "OrderBy": case "OrderByDescending": case "ThenBy": case "ThenByDescending": { if (invocation.Arguments.Count != 1) { return(null); } string parameterName; Expression orderExpression; if (MatchSimpleLambda(invocation.Arguments.Single(), out parameterName, out orderExpression)) { if (ValidateThenByChain(invocation, parameterName)) { QueryOrderClause orderClause = new QueryOrderClause(); InvocationExpression tmp = invocation; while (mre.MemberName == "ThenBy" || mre.MemberName == "ThenByDescending") { // insert new ordering at beginning orderClause.Orderings.InsertAfter( null, new QueryOrdering { Expression = Detach(orderExpression), Direction = (mre.MemberName == "ThenBy" ? QueryOrderingDirection.None : QueryOrderingDirection.Descending) }); tmp = (InvocationExpression)mre.Target; mre = (MemberReferenceExpression)tmp.Target; MatchSimpleLambda(tmp.Arguments.Single(), out parameterName, out orderExpression); } // insert new ordering at beginning orderClause.Orderings.InsertAfter( null, new QueryOrdering { Expression = Detach(orderExpression), Direction = (mre.MemberName == "OrderBy" ? QueryOrderingDirection.None : QueryOrderingDirection.Descending) }); QueryExpression query = new QueryExpression(); query.Clauses.Add(new QueryFromClause { Identifier = parameterName, Expression = Detach(mre.Target) }); query.Clauses.Add(orderClause); return(query); } } return(null); } case "Join": case "GroupJoin": { if (invocation.Arguments.Count != 4) { return(null); } Expression source1 = mre.Target; Expression source2 = invocation.Arguments.ElementAt(0); string elementName1, elementName2; Expression key1, key2; if (!MatchSimpleLambda(invocation.Arguments.ElementAt(1), out elementName1, out key1)) { return(null); } if (!MatchSimpleLambda(invocation.Arguments.ElementAt(2), out elementName2, out key2)) { return(null); } LambdaExpression lambda = invocation.Arguments.ElementAt(3) as LambdaExpression; if (lambda != null && lambda.Parameters.Count == 2 && lambda.Body is Expression) { ParameterDeclaration p1 = lambda.Parameters.ElementAt(0); ParameterDeclaration p2 = lambda.Parameters.ElementAt(1); if (p1.Name == elementName1 && (p2.Name == elementName2 || mre.MemberName == "GroupJoin")) { QueryExpression query = new QueryExpression(); query.Clauses.Add(new QueryFromClause { Identifier = elementName1, Expression = Detach(source1) }); QueryJoinClause joinClause = new QueryJoinClause(); joinClause.JoinIdentifier = elementName2; // join elementName2 joinClause.InExpression = Detach(source2); // in source2 joinClause.OnExpression = Detach(key1); // on key1 joinClause.EqualsExpression = Detach(key2); // equals key2 if (mre.MemberName == "GroupJoin") { joinClause.IntoIdentifier = p2.Name; // into p2.Name } query.Clauses.Add(joinClause); query.Clauses.Add(new QuerySelectClause { Expression = Detach(((Expression)lambda.Body)) }); return(query); } } return(null); } default: return(null); } }
public virtual void VisitQueryJoinClause(QueryJoinClause queryJoinClause) { if (this.ThrowException) { throw (Exception)this.CreateException(queryJoinClause); } }
public override object Visit (Mono.CSharp.Linq.GroupJoin join) { var result = new QueryJoinClause (); var location = LocationsBag.GetLocations (join); result.AddChild (new CSharpTokenNode (Convert (join.Location), "join".Length), QueryJoinClause.JoinKeywordRole); result.AddChild (Identifier.Create (join.JoinVariable.Name, Convert (join.JoinVariable.Location)), Identifier.Roles.Identifier); if (location != null) result.AddChild (new CSharpTokenNode (Convert (location[0]), "in".Length), QueryJoinClause.InKeywordRole); result.AddChild ((Expression)join.Expr.Accept (this), QueryJoinClause.Roles.Expression); if (location != null) result.AddChild (new CSharpTokenNode (Convert (location[1]), "on".Length), QueryJoinClause.OnKeywordRole); // TODO: on expression if (location != null) result.AddChild (new CSharpTokenNode (Convert (location[2]), "equals".Length), QueryJoinClause.EqualsKeywordRole); // TODO: equals expression if (location != null) result.AddChild (new CSharpTokenNode (Convert (location[3]), "into".Length), QueryJoinClause.IntoKeywordRole); result.AddChild (Identifier.Create (join.JoinVariable.Name, Convert (join.JoinVariable.Location)), Identifier.Roles.Identifier); return result; }
public virtual void VisitQueryJoinClause(QueryJoinClause queryJoinClause) { DebugExpression(queryJoinClause); StartNode(queryJoinClause); WriteKeyword(QueryJoinClause.JoinKeywordRole); queryJoinClause.Type.AcceptVisitor(this); Space(); WriteIdentifier(queryJoinClause.JoinIdentifierToken, CSharpMetadataTextColorProvider.Instance.GetColor(queryJoinClause.JoinIdentifierToken.Annotation<object>())); Space(); WriteKeyword(QueryJoinClause.InKeywordRole); Space(); queryJoinClause.InExpression.AcceptVisitor(this); Space(); WriteKeyword(QueryJoinClause.OnKeywordRole); Space(); queryJoinClause.OnExpression.AcceptVisitor(this); Space(); WriteKeyword(QueryJoinClause.EqualsKeywordRole); Space(); queryJoinClause.EqualsExpression.AcceptVisitor(this); if (queryJoinClause.IsGroupJoin) { Space(); WriteKeyword(QueryJoinClause.IntoKeywordRole); WriteIdentifier(queryJoinClause.IntoIdentifierToken, CSharpMetadataTextColorProvider.Instance.GetColor(queryJoinClause.IntoIdentifierToken.Annotation<object>())); } EndNode(queryJoinClause); }
public StringBuilder VisitQueryJoinClause(QueryJoinClause queryJoinClause) { return(InvalidNode(queryJoinClause, "LINQ is not supported")); }
public UnifiedElement VisitQueryJoinClause( QueryJoinClause queryJoinClause, object data) { throw new NotImplementedException("QueryJoinClause"); }
public Node VisitQueryJoinClause(QueryJoinClause queryJoinClause) { return(CreateDummy(queryJoinClause)); }
public void VisitQueryJoinClause(QueryJoinClause queryJoinClause) { throw new NotImplementedException(); }
public virtual S VisitQueryJoinClause(QueryJoinClause queryJoinClause, T data) { return(VisitChildren(queryJoinClause, data)); }
public StringBuilder VisitQueryJoinClause(QueryJoinClause queryJoinClause, int data) { throw new SLSharpException("SL# does not understand LINQ."); }
public override void VisitQueryJoinClause(QueryJoinClause queryJoinClause) { FixClauseIndentation(queryJoinClause, queryJoinClause.JoinKeyword); }
public override void VisitQueryJoinClause(QueryJoinClause queryJoinClause) { queryJoinClause.InExpression.AcceptVisitor(this); }
public override void VisitQueryJoinClause(QueryJoinClause syntax) { _underlyingVisitor.VisitQueryJoinClause(syntax); }
public override object Visit(Mono.CSharp.Linq.Join join) { var result = new QueryJoinClause(); var location = LocationsBag.GetLocations(join); result.AddChild(new CSharpTokenNode(Convert(join.Location), QueryJoinClause.JoinKeywordRole), QueryJoinClause.JoinKeywordRole); if (join.IdentifierType != null) result.AddChild(ConvertToType(join.IdentifierType), QueryJoinClause.TypeRole); result.AddChild(Identifier.Create(join.JoinVariable.Name, Convert(join.JoinVariable.Location)), QueryJoinClause.JoinIdentifierRole); if (join.IdentifierType != null) result.AddChild(ConvertToType(join.IdentifierType), QueryJoinClause.TypeRole); if (location != null) result.AddChild(new CSharpTokenNode(Convert(location [0]), QueryJoinClause.InKeywordRole), QueryJoinClause.InKeywordRole); if (join.Expr != null) result.AddChild((Expression)join.Expr.Accept(this), QueryJoinClause.InExpressionRole); if (location != null && location.Count > 1) result.AddChild(new CSharpTokenNode(Convert(location [1]), QueryJoinClause.OnKeywordRole), QueryJoinClause.OnKeywordRole); var outer = join.OuterSelector.Statements.FirstOrDefault() as ContextualReturn; if (outer != null) result.AddChild((Expression)outer.Expr.Accept(this), QueryJoinClause.OnExpressionRole); if (location != null && location.Count > 2) result.AddChild(new CSharpTokenNode(Convert(location [2]), QueryJoinClause.EqualsKeywordRole), QueryJoinClause.EqualsKeywordRole); var inner = join.InnerSelector.Statements.FirstOrDefault() as ContextualReturn; if (inner != null) result.AddChild((Expression)inner.Expr.Accept(this), QueryJoinClause.EqualsExpressionRole); return result; }
QueryExpression DecompileQuery(InvocationExpression invocation) { if (invocation == null) return null; MemberReferenceExpression mre = invocation.Target as MemberReferenceExpression; if (mre == null) return null; switch (mre.MemberName) { case "Select": { if (invocation.Arguments.Count != 1) return null; string parameterName; Expression body; if (MatchSimpleLambda(invocation.Arguments.Single(), out parameterName, out body)) { QueryExpression query = new QueryExpression(); query.Clauses.Add(new QueryFromClause { Identifier = parameterName, Expression = mre.Target.Detach() }); query.Clauses.Add(new QuerySelectClause { Expression = body.Detach() }); return query; } return null; } case "GroupBy": { if (invocation.Arguments.Count == 2) { string parameterName1, parameterName2; Expression keySelector, elementSelector; if (MatchSimpleLambda(invocation.Arguments.ElementAt(0), out parameterName1, out keySelector) && MatchSimpleLambda(invocation.Arguments.ElementAt(1), out parameterName2, out elementSelector) && parameterName1 == parameterName2) { QueryExpression query = new QueryExpression(); query.Clauses.Add(new QueryFromClause { Identifier = parameterName1, Expression = mre.Target.Detach() }); query.Clauses.Add(new QueryGroupClause { Projection = elementSelector.Detach(), Key = keySelector.Detach() }); return query; } } else if (invocation.Arguments.Count == 1) { string parameterName; Expression keySelector; if (MatchSimpleLambda(invocation.Arguments.Single(), out parameterName, out keySelector)) { QueryExpression query = new QueryExpression(); query.Clauses.Add(new QueryFromClause { Identifier = parameterName, Expression = mre.Target.Detach() }); query.Clauses.Add(new QueryGroupClause { Projection = new IdentifierExpression(parameterName), Key = keySelector.Detach() }); return query; } } return null; } case "SelectMany": { if (invocation.Arguments.Count != 2) return null; string parameterName; Expression collectionSelector; if (!MatchSimpleLambda(invocation.Arguments.ElementAt(0), out parameterName, out collectionSelector)) return null; LambdaExpression lambda = invocation.Arguments.ElementAt(1) as LambdaExpression; if (lambda != null && lambda.Parameters.Count == 2 && lambda.Body is Expression) { ParameterDeclaration p1 = lambda.Parameters.ElementAt(0); ParameterDeclaration p2 = lambda.Parameters.ElementAt(1); if (p1.Name == parameterName) { QueryExpression query = new QueryExpression(); query.Clauses.Add(new QueryFromClause { Identifier = p1.Name, Expression = mre.Target.Detach() }); query.Clauses.Add(new QueryFromClause { Identifier = p2.Name, Expression = collectionSelector.Detach() }); query.Clauses.Add(new QuerySelectClause { Expression = ((Expression)lambda.Body).Detach() }); return query; } } return null; } case "Where": { if (invocation.Arguments.Count != 1) return null; string parameterName; Expression body; if (MatchSimpleLambda(invocation.Arguments.Single(), out parameterName, out body)) { QueryExpression query = new QueryExpression(); query.Clauses.Add(new QueryFromClause { Identifier = parameterName, Expression = mre.Target.Detach() }); query.Clauses.Add(new QueryWhereClause { Condition = body.Detach() }); return query; } return null; } case "OrderBy": case "OrderByDescending": case "ThenBy": case "ThenByDescending": { if (invocation.Arguments.Count != 1) return null; string parameterName; Expression orderExpression; if (MatchSimpleLambda(invocation.Arguments.Single(), out parameterName, out orderExpression)) { if (ValidateThenByChain(invocation, parameterName)) { QueryOrderClause orderClause = new QueryOrderClause(); InvocationExpression tmp = invocation; while (mre.MemberName == "ThenBy" || mre.MemberName == "ThenByDescending") { // insert new ordering at beginning orderClause.Orderings.InsertAfter( null, new QueryOrdering { Expression = orderExpression.Detach(), Direction = (mre.MemberName == "ThenBy" ? QueryOrderingDirection.None : QueryOrderingDirection.Descending) }); tmp = (InvocationExpression)mre.Target; mre = (MemberReferenceExpression)tmp.Target; MatchSimpleLambda(tmp.Arguments.Single(), out parameterName, out orderExpression); } // insert new ordering at beginning orderClause.Orderings.InsertAfter( null, new QueryOrdering { Expression = orderExpression.Detach(), Direction = (mre.MemberName == "OrderBy" ? QueryOrderingDirection.None : QueryOrderingDirection.Descending) }); QueryExpression query = new QueryExpression(); query.Clauses.Add(new QueryFromClause { Identifier = parameterName, Expression = mre.Target.Detach() }); query.Clauses.Add(orderClause); return query; } } return null; } case "Join": case "GroupJoin": { if (invocation.Arguments.Count != 4) return null; Expression source1 = mre.Target; Expression source2 = invocation.Arguments.ElementAt(0); string elementName1, elementName2; Expression key1, key2; if (!MatchSimpleLambda(invocation.Arguments.ElementAt(1), out elementName1, out key1)) return null; if (!MatchSimpleLambda(invocation.Arguments.ElementAt(2), out elementName2, out key2)) return null; LambdaExpression lambda = invocation.Arguments.ElementAt(3) as LambdaExpression; if (lambda != null && lambda.Parameters.Count == 2 && lambda.Body is Expression) { ParameterDeclaration p1 = lambda.Parameters.ElementAt(0); ParameterDeclaration p2 = lambda.Parameters.ElementAt(1); if (p1.Name == elementName1 && (p2.Name == elementName2 || mre.MemberName == "GroupJoin")) { QueryExpression query = new QueryExpression(); query.Clauses.Add(new QueryFromClause { Identifier = elementName1, Expression = source1.Detach() }); QueryJoinClause joinClause = new QueryJoinClause(); joinClause.JoinIdentifier = elementName2; // join elementName2 joinClause.InExpression = source2.Detach(); // in source2 joinClause.OnExpression = key1.Detach(); // on key1 joinClause.EqualsExpression = key2.Detach(); // equals key2 if (mre.MemberName == "GroupJoin") { joinClause.IntoIdentifier = p2.Name; // into p2.Name } query.Clauses.Add(joinClause); query.Clauses.Add(new QuerySelectClause { Expression = ((Expression)lambda.Body).Detach() }); return query; } } return null; } default: return null; } }
public virtual void VisitQueryJoinClause(QueryJoinClause queryJoinClause) { VisitChildren (queryJoinClause); }
QueryExpression DecompileQuery(InvocationExpression invocation) { if (invocation == null) { return(null); } MemberReferenceExpression mre = invocation.Target as MemberReferenceExpression; if (mre == null || IsNullConditional(mre.Target)) { return(null); } switch (mre.MemberName) { case "Select": { if (invocation.Arguments.Count != 1) { return(null); } if (!IsComplexQuery(mre)) { return(null); } ParameterDeclaration parameter; Expression body; if (MatchSimpleLambda(invocation.Arguments.Single(), out parameter, out body)) { QueryExpression query = new QueryExpression(); query.Clauses.Add(MakeFromClause(parameter, mre.Target.Detach())); query.Clauses.Add(new QuerySelectClause { Expression = WrapExpressionInParenthesesIfNecessary(body.Detach(), parameter.Name) }); return(query); } return(null); } case "GroupBy": { if (invocation.Arguments.Count == 2) { ParameterDeclaration parameter1, parameter2; Expression keySelector, elementSelector; if (MatchSimpleLambda(invocation.Arguments.ElementAt(0), out parameter1, out keySelector) && MatchSimpleLambda(invocation.Arguments.ElementAt(1), out parameter2, out elementSelector) && parameter1.Name == parameter2.Name) { QueryExpression query = new QueryExpression(); query.Clauses.Add(MakeFromClause(parameter1, mre.Target.Detach())); query.Clauses.Add(new QueryGroupClause { Projection = elementSelector.Detach(), Key = keySelector.Detach() }); return(query); } } else if (invocation.Arguments.Count == 1) { ParameterDeclaration parameter; Expression keySelector; if (MatchSimpleLambda(invocation.Arguments.Single(), out parameter, out keySelector)) { QueryExpression query = new QueryExpression(); query.Clauses.Add(MakeFromClause(parameter, mre.Target.Detach())); query.Clauses.Add(new QueryGroupClause { Projection = new IdentifierExpression(parameter.Name).CopyAnnotationsFrom(parameter), Key = keySelector.Detach() }); return(query); } } return(null); } case "SelectMany": { if (invocation.Arguments.Count != 2) { return(null); } ParameterDeclaration parameter; Expression collectionSelector; if (!MatchSimpleLambda(invocation.Arguments.ElementAt(0), out parameter, out collectionSelector)) { return(null); } if (IsNullConditional(collectionSelector)) { return(null); } LambdaExpression lambda = invocation.Arguments.ElementAt(1) as LambdaExpression; if (lambda != null && lambda.Parameters.Count == 2 && lambda.Body is Expression) { ParameterDeclaration p1 = lambda.Parameters.ElementAt(0); ParameterDeclaration p2 = lambda.Parameters.ElementAt(1); if (p1.Name == parameter.Name) { QueryExpression query = new QueryExpression(); query.Clauses.Add(MakeFromClause(p1, mre.Target.Detach())); query.Clauses.Add(MakeFromClause(p2, collectionSelector.Detach())); query.Clauses.Add(new QuerySelectClause { Expression = WrapExpressionInParenthesesIfNecessary(((Expression)lambda.Body).Detach(), parameter.Name) }); return(query); } } return(null); } case "Where": { if (invocation.Arguments.Count != 1) { return(null); } if (!IsComplexQuery(mre)) { return(null); } ParameterDeclaration parameter; Expression body; if (MatchSimpleLambda(invocation.Arguments.Single(), out parameter, out body)) { QueryExpression query = new QueryExpression(); query.Clauses.Add(MakeFromClause(parameter, mre.Target.Detach())); query.Clauses.Add(new QueryWhereClause { Condition = body.Detach() }); return(query); } return(null); } case "OrderBy": case "OrderByDescending": case "ThenBy": case "ThenByDescending": { if (invocation.Arguments.Count != 1) { return(null); } if (!IsComplexQuery(mre)) { return(null); } ParameterDeclaration parameter; Expression orderExpression; if (MatchSimpleLambda(invocation.Arguments.Single(), out parameter, out orderExpression)) { if (ValidateThenByChain(invocation, parameter.Name)) { QueryOrderClause orderClause = new QueryOrderClause(); InvocationExpression tmp = invocation; while (mre.MemberName == "ThenBy" || mre.MemberName == "ThenByDescending") { // insert new ordering at beginning orderClause.Orderings.InsertAfter( null, new QueryOrdering { Expression = orderExpression.Detach(), Direction = (mre.MemberName == "ThenBy" ? QueryOrderingDirection.None : QueryOrderingDirection.Descending) }); tmp = (InvocationExpression)mre.Target; mre = (MemberReferenceExpression)tmp.Target; MatchSimpleLambda(tmp.Arguments.Single(), out parameter, out orderExpression); } // insert new ordering at beginning orderClause.Orderings.InsertAfter( null, new QueryOrdering { Expression = orderExpression.Detach(), Direction = (mre.MemberName == "OrderBy" ? QueryOrderingDirection.None : QueryOrderingDirection.Descending) }); QueryExpression query = new QueryExpression(); query.Clauses.Add(MakeFromClause(parameter, mre.Target.Detach())); query.Clauses.Add(orderClause); return(query); } } return(null); } case "Join": case "GroupJoin": { if (invocation.Arguments.Count != 4) { return(null); } Expression source1 = mre.Target; Expression source2 = invocation.Arguments.ElementAt(0); if (IsNullConditional(source2)) { return(null); } ParameterDeclaration element1, element2; Expression key1, key2; if (!MatchSimpleLambda(invocation.Arguments.ElementAt(1), out element1, out key1)) { return(null); } if (!MatchSimpleLambda(invocation.Arguments.ElementAt(2), out element2, out key2)) { return(null); } LambdaExpression lambda = invocation.Arguments.ElementAt(3) as LambdaExpression; if (lambda != null && lambda.Parameters.Count == 2 && lambda.Body is Expression) { ParameterDeclaration p1 = lambda.Parameters.ElementAt(0); ParameterDeclaration p2 = lambda.Parameters.ElementAt(1); if (p1.Name == element1.Name && (p2.Name == element2.Name || mre.MemberName == "GroupJoin")) { QueryExpression query = new QueryExpression(); query.Clauses.Add(MakeFromClause(element1, source1.Detach())); QueryJoinClause joinClause = new QueryJoinClause(); joinClause.JoinIdentifier = element2.Name; // join elementName2 joinClause.InExpression = source2.Detach(); // in source2 joinClause.OnExpression = key1.Detach(); // on key1 joinClause.EqualsExpression = key2.Detach(); // equals key2 if (mre.MemberName == "GroupJoin") { joinClause.IntoIdentifier = p2.Name; // into p2.Name } query.Clauses.Add(joinClause); query.Clauses.Add(new QuerySelectClause { Expression = ((Expression)lambda.Body).Detach() }); return(query); } } return(null); } default: return(null); } }
public StringBuilder VisitQueryJoinClause(QueryJoinClause queryJoinClause, int data) { throw new ASLException("ASL does not understand LINQ."); }
public override object Visit(Mono.CSharp.Linq.GroupJoin groupJoin) { var result = new QueryJoinClause(); var location = LocationsBag.GetLocations(groupJoin); result.AddChild(new CSharpTokenNode(Convert(groupJoin.Location), QueryJoinClause.JoinKeywordRole), QueryJoinClause.JoinKeywordRole); // mcs seems to have swapped IntoVariable with JoinVariable, so we'll swap it back here result.AddChild(Identifier.Create(groupJoin.IntoVariable.Name, Convert(groupJoin.IntoVariable.Location)), QueryJoinClause.JoinIdentifierRole); if (location != null) result.AddChild(new CSharpTokenNode(Convert(location [0]), QueryJoinClause.InKeywordRole), QueryJoinClause.InKeywordRole); if (groupJoin.Expr != null) result.AddChild((Expression)groupJoin.Expr.Accept(this), QueryJoinClause.InExpressionRole); if (location != null && location.Count > 1) result.AddChild(new CSharpTokenNode(Convert(location [1]), QueryJoinClause.OnKeywordRole), QueryJoinClause.OnKeywordRole); var outer = groupJoin.OuterSelector.Statements.FirstOrDefault() as ContextualReturn; if (outer != null) result.AddChild((Expression)outer.Expr.Accept(this), QueryJoinClause.OnExpressionRole); if (location != null && location.Count > 2) result.AddChild(new CSharpTokenNode(Convert(location [2]), QueryJoinClause.EqualsKeywordRole), QueryJoinClause.EqualsKeywordRole); var inner = groupJoin.InnerSelector.Statements.FirstOrDefault() as ContextualReturn; if (inner != null) result.AddChild((Expression)inner.Expr.Accept(this), QueryJoinClause.EqualsExpressionRole); if (location != null && location.Count > 3) result.AddChild(new CSharpTokenNode(Convert(location [3]), QueryJoinClause.IntoKeywordRole), QueryJoinClause.IntoKeywordRole); result.AddChild(Identifier.Create(groupJoin.JoinVariable.Name, Convert(groupJoin.JoinVariable.Location)), QueryJoinClause.IntoIdentifierRole); return result; }
public JNode VisitQueryJoinClause(QueryJoinClause node) { throw new NotImplementedException(); }
public void VisitQueryJoinClause(QueryJoinClause queryJoinClause) { StartNode(queryJoinClause); WriteKeyword(QueryJoinClause.JoinKeywordRole); queryJoinClause.Type.AcceptVisitor(this); Space(); WriteIdentifier(queryJoinClause.JoinIdentifier, QueryJoinClause.JoinIdentifierRole); Space(); WriteKeyword(QueryJoinClause.InKeywordRole); Space(); queryJoinClause.InExpression.AcceptVisitor(this); Space(); WriteKeyword(QueryJoinClause.OnKeywordRole); Space(); queryJoinClause.OnExpression.AcceptVisitor(this); Space(); WriteKeyword(QueryJoinClause.EqualsKeywordRole); Space(); queryJoinClause.EqualsExpression.AcceptVisitor(this); if (queryJoinClause.IsGroupJoin) { Space(); WriteKeyword(QueryJoinClause.IntoKeywordRole); WriteIdentifier(queryJoinClause.IntoIdentifier, QueryJoinClause.IntoIdentifierRole); } EndNode(queryJoinClause); }
public virtual Node VisitQueryJoinClause(QueryJoinClause queryJoinClause) { throw new System.NotImplementedException(); }