public string CombineQuery(AstNode node, AstNode rootQuery = null)
        {
            if (rootQuery == null)
            {
                rootQuery = node;
            }

            QueryExpression query = node as QueryExpression;

            if (query != null)
            {
                string continuationIdentifier = null;

                foreach (var clause in query.Clauses)
                {
                    var continuation = clause as QueryContinuationClause;
                    if (continuation != null)
                    {
                        CombineQuery(continuation.PrecedingQuery);
                    }

                    var from = clause as QueryFromClause;
                    if (from != null)
                    {
                        continuationIdentifier = CombineQuery(from.Expression, rootQuery);
                    }
                }

                QueryFromClause fromClause = (QueryFromClause)query.Clauses.First();
                QueryExpression innerQuery = fromClause.Expression as QueryExpression;
                if (innerQuery != null)
                {
                    continuationIdentifier = continuationIdentifier ?? ((QueryFromClause)innerQuery.Clauses.First()).Identifier;

                    string transparentIdentifier;
                    if (TryRemoveTransparentIdentifier(query, fromClause, innerQuery, continuationIdentifier, out transparentIdentifier))
                    {
                        RemoveTransparentIdentifierReferences(rootQuery, transparentIdentifier);
                    }
                    else if (fromClause.Type.IsNull)
                    {
                        QueryContinuationClause continuation = new QueryContinuationClause();
                        continuation.PrecedingQuery = innerQuery.Detach();
                        continuation.Identifier     = fromClause.Identifier;
                        fromClause.ReplaceWith(continuation);
                    }

                    return(transparentIdentifier);
                }
                else
                {
                    Match m = castPattern.Match(fromClause.Expression);
                    if (m.Success)
                    {
                        fromClause.Type       = m.Get <AstType>("targetType").Single().Detach();
                        fromClause.Expression = m.Get <Expression>("inExpr").Single().Detach();
                    }
                }
            }

            return(null);
        }
Exemplo n.º 2
0
        protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
        {
            QueryContinuationClause o = other as QueryContinuationClause;

            return(o != null && MatchString(this.Identifier, o.Identifier) && this.PrecedingQuery.DoMatch(o.PrecedingQuery, match));
        }
Exemplo n.º 3
0
 void IAstVisitor.VisitQueryContinuationClause(QueryContinuationClause queryContinuationClause)
 {
     Visit(EnterQueryContinuationClause, LeaveQueryContinuationClause, queryContinuationClause);
 }
 public override void VisitQueryContinuationClause(QueryContinuationClause queryContinuationClause)
 {
     VisitChildren(queryContinuationClause);
 }