public override SearchParameterQueryGeneratorContext VisitSearchParameter(SearchParameterExpression expression, SearchParameterQueryGeneratorContext context)
        {
            SearchParameterQueryGenerator delegatedGenerator = GetSearchParameterQueryGeneratorIfResourceColumnSearchParameter(expression);

            if (delegatedGenerator != null)
            {
                // This is a search parameter over a column that exists on the Resource table or both the Resource table and search parameter tables.
                // Delegate to the visitor specific to it.
                return(expression.Expression.AcceptVisitor(delegatedGenerator, context));
            }

            short          searchParamId       = context.Model.GetSearchParamId(expression.Parameter.Url);
            SmallIntColumn searchParamIdColumn = VLatest.SearchParam.SearchParamId;

            context.StringBuilder
            .Append(searchParamIdColumn, context.TableAlias)
            .Append(" = ")
            .AppendLine(context.Parameters.AddParameter(searchParamIdColumn, searchParamId, true).ParameterName)
            .Append("AND ");

            return(expression.Expression.AcceptVisitor(this, context));
        }
예제 #2
0
        public override SearchParameterQueryGeneratorContext VisitMissingSearchParameter(MissingSearchParameterExpression expression, SearchParameterQueryGeneratorContext context)
        {
            SearchParameterQueryGenerator delegatedGenerator = GetSearchParameterQueryGeneratorIfResourceColumnSearchParameter(expression);

            if (delegatedGenerator != null)
            {
                // This is a search parameter over a column that exists on the Resource table or both the Resource table and search parameter tables.
                // Delegate to the visitor specific to it.
                return(expression.AcceptVisitor(delegatedGenerator, context));
            }

            Debug.Assert(!expression.IsMissing, "IsMissing=true expressions should have been rewritten");

            short          searchParamId       = context.Model.GetSearchParamId(expression.Parameter.Url);
            SmallIntColumn searchParamIdColumn = VLatest.SearchParam.SearchParamId;

            context.StringBuilder
            .Append(searchParamIdColumn, context.TableAlias)
            .Append(" = ")
            .AppendLine(context.Parameters.AddParameter(searchParamIdColumn, searchParamId).ParameterName);

            return(context);
        }