private void ProcessChainedExpression(ChainedExpression chainedExpression, List <SearchParamTableExpression> tableExpressions, int chainLevel)
        {
            SearchParamTableExpressionQueryGenerator queryGenerator = chainedExpression.Expression.AcceptVisitor(_searchParamTableExpressionQueryGeneratorFactory, null);

            Expression expressionOnTarget = queryGenerator == null ? chainedExpression.Expression : null;

            var sqlChainLinkExpression = new SqlChainLinkExpression(
                chainedExpression.ResourceTypes,
                chainedExpression.ReferenceSearchParameter,
                chainedExpression.TargetResourceTypes,
                chainedExpression.Reversed,
                expressionOnTarget: expressionOnTarget);

            tableExpressions.Add(
                new SearchParamTableExpression(
                    ChainLinkQueryGenerator.Instance,
                    sqlChainLinkExpression,
                    SearchParamTableExpressionKind.Chain,
                    chainLevel));

            if (chainedExpression.Expression is ChainedExpression nestedChainedExpression)
            {
                ProcessChainedExpression(nestedChainedExpression, tableExpressions, chainLevel + 1);
            }
            else if (queryGenerator != null)
            {
                tableExpressions.Add(
                    new SearchParamTableExpression(
                        queryGenerator,
                        chainedExpression.Expression,
                        SearchParamTableExpressionKind.Normal,
                        chainLevel));
            }
        }
예제 #2
0
 /// <summary>
 /// Creates a new instance of the <see cref="SearchParamTableExpression"/> class.
 /// </summary>
 /// <param name="queryGenerator">The search parameter query generator</param>
 /// <param name="predicate">The search expression over a columns belonging exclusively to a search parameter table.
 /// Applies to the chain target if a chained expression.</param>
 /// <param name="kind">The table expression kind.</param>
 /// <param name="chainLevel">The nesting chain nesting level of the current expression. 0 if not a chain expression.</param>
 public SearchParamTableExpression(
     SearchParamTableExpressionQueryGenerator queryGenerator,
     Expression predicate,
     SearchParamTableExpressionKind kind,
     int chainLevel = 0)
 {
     QueryGenerator = queryGenerator;
     Predicate      = predicate;
     Kind           = kind;
     ChainLevel     = chainLevel;
 }