public override void VisitWhereClause(WhereClause whereClause, QueryModel queryModel, int index) { var visitor = new SimplifyConditionalVisitor(); whereClause.Predicate = visitor.Visit(whereClause.Predicate); // Visit the predicate to build the query var expression = HqlGeneratorExpressionVisitor.Visit(whereClause.Predicate, VisitorParameters).ToBooleanExpression(); _hqlTree.AddWhereClause(expression); }
public override void VisitWhereClause(WhereClause whereClause, QueryModel queryModel, int index) { // Visit the predicate to build the query var expression = HqlGeneratorExpressionTreeVisitor.Visit(whereClause.Predicate, VisitorParameters).AsBooleanExpression(); if (whereClause is NhHavingClause) { _hqlTree.AddHavingClause(expression); } else { _hqlTree.AddWhereClause(expression); } }
public void Process(ContainsResultOperator resultOperator, QueryModelVisitor queryModelVisitor, IntermediateHqlTree tree) { var itemExpression = HqlGeneratorExpressionTreeVisitor.Visit(resultOperator.Item, queryModelVisitor.VisitorParameters) .AsExpression(); var from = GetFromRangeClause(tree.Root); var source = from.Children.First(); if (source is HqlParameter) { // This is an "in" style statement if (IsEmptyList((HqlParameter)source, queryModelVisitor.VisitorParameters)) { // if the list is empty the expression will always be false, so generate "1 = 0" tree.SetRoot(tree.TreeBuilder.Equality(tree.TreeBuilder.Constant(1), tree.TreeBuilder.Constant(0))); } else { tree.SetRoot(tree.TreeBuilder.In(itemExpression, source)); } } else { // This is an "exists" style statement tree.AddWhereClause(tree.TreeBuilder.Equality( tree.TreeBuilder.Ident(GetFromAlias(tree.Root).AstNode.Text), itemExpression)); tree.SetRoot(tree.TreeBuilder.Exists((HqlQuery)tree.Root)); } }
public void Process(AllResultOperator resultOperator, QueryModelVisitor queryModelVisitor, IntermediateHqlTree tree) { tree.AddWhereClause(tree.TreeBuilder.BooleanNot( HqlGeneratorExpressionTreeVisitor.Visit(resultOperator.Predicate, queryModelVisitor.VisitorParameters). ToBooleanExpression())); tree.SetRoot(tree.TreeBuilder.BooleanNot(tree.TreeBuilder.Exists((HqlQuery)tree.Root))); }
public void Process(OfTypeResultOperator resultOperator, QueryModelVisitor queryModelVisitor, IntermediateHqlTree tree) { var source = queryModelVisitor.Model.SelectClause.GetOutputDataInfo().ItemExpression; var expression = new HqlGeneratorExpressionTreeVisitor(queryModelVisitor.VisitorParameters) .BuildOfType(source, resultOperator.SearchedItemType); tree.AddWhereClause(expression); }
public void Process(OfTypeResultOperator resultOperator, QueryModelVisitor queryModelVisitor, IntermediateHqlTree tree) { Expression source = queryModelVisitor.Model.SelectClause.GetOutputDataInfo().ItemExpression; tree.AddWhereClause(tree.TreeBuilder.Equality( tree.TreeBuilder.Dot( HqlGeneratorExpressionTreeVisitor.Visit(source, queryModelVisitor.VisitorParameters).AsExpression(), tree.TreeBuilder.Class()), tree.TreeBuilder.Ident(resultOperator.SearchedItemType.FullName))); }
public void Process(OfTypeResultOperator resultOperator, QueryModelVisitor queryModelVisitor, IntermediateHqlTree tree) { Expression source = queryModelVisitor.CurrentEvaluationType.As <StreamedSequenceInfo>().ItemExpression; tree.AddWhereClause(tree.TreeBuilder.Equality( tree.TreeBuilder.Dot( HqlGeneratorExpressionTreeVisitor.Visit(source, queryModelVisitor.VisitorParameters).AsExpression(), tree.TreeBuilder.Class()), tree.TreeBuilder.Ident(resultOperator.SearchedItemType.FullName))); }
public void Process(AllResultOperator resultOperator, QueryModelVisitor queryModelVisitor, IntermediateHqlTree tree) { tree.AddWhereClause(tree.TreeBuilder.BooleanNot( HqlGeneratorExpressionTreeVisitor.Visit(resultOperator.Predicate, queryModelVisitor.VisitorParameters). ToBooleanExpression())); if (tree.IsRoot) { tree.AddTakeClause(tree.TreeBuilder.Constant(1)); Expression <Func <IEnumerable <object>, bool> > x = l => !l.Any(); tree.AddListTransformer(x); } else { tree.SetRoot(tree.TreeBuilder.BooleanNot(tree.TreeBuilder.Exists((HqlQuery)tree.Root))); } }
public void Process(AllResultOperator resultOperator, QueryModelVisitor queryModelVisitor, IntermediateHqlTree tree) { tree.AddWhereClause(tree.TreeBuilder.BooleanNot( HqlGeneratorExpressionVisitor.Visit(resultOperator.Predicate, queryModelVisitor.VisitorParameters). ToBooleanExpression())); if (tree.IsRoot) { tree.AddTakeClause(tree.TreeBuilder.Constant(1)); Expression <Func <IEnumerable <object>, bool> > x = l => !l.Any(); tree.AddListTransformer(x); // NH-3850: Queries with polymorphism yields many results which must be combined. Expression <Func <IEnumerable <bool>, bool> > px = l => l.All(r => r); tree.AddPostExecuteTransformer(px); } else { tree.SetRoot(tree.TreeBuilder.BooleanNot(tree.TreeBuilder.Exists((HqlQuery)tree.Root))); } }
public override void VisitWhereClause(WhereClause whereClause, QueryModel queryModel, int index) { // Visit the predicate to build the query _hqlTree.AddWhereClause(HqlGeneratorExpressionTreeVisitor.Visit(whereClause.Predicate, VisitorParameters).AsBooleanExpression()); }