Example #1
0
        public static Expression GetSparqlExpression(Expression expression, SparqlQueryBuilder queryBuilder)
        {
            var visitor            = new SparqlGeneratorWhereExpressionTreeVisitor(queryBuilder);
            var returnedExpression = visitor.VisitExpression(expression);

            if (returnedExpression is SelectVariableNameExpression && expression.Type.Equals(typeof(bool)))
            {
                var svn = (SelectVariableNameExpression)returnedExpression;
                // Single boolean member expression requires a special case addition to the filter
                queryBuilder.AddFilterExpression("(?" + svn.Name + " = true)");
            }
            queryBuilder.AddFilterExpression(visitor.FilterExpression);
            return(returnedExpression);
        }
        public static Expression GetSparqlExpression(Expression expression, SparqlQueryBuilder queryBuilder, bool filterOptimizationEnabled)
        {
            var canOptimizeFilter  = filterOptimizationEnabled && CanOptimizeFilter(expression, queryBuilder);
            var visitor            = new SparqlGeneratorWhereExpressionTreeVisitor(queryBuilder, canOptimizeFilter, expression.Type == typeof(bool));
            var returnedExpression = visitor.VisitExpression(expression);
            var svn = returnedExpression as SelectVariableNameExpression;

            if (svn != null && expression.Type == typeof(bool))
            {
                // Single boolean member expression requires a special case addition to the filter
                queryBuilder.AddFilterExpression("(?" + svn.Name + " = true)");
            }
            queryBuilder.AddFilterExpression(visitor.FilterExpression);
            return(returnedExpression);
        }
 protected override Expression VisitBinaryExpression(BinaryExpression expression)
 {
     return(_parent.VisitExpression(expression, this.InBooleanExpression));
 }