public override HqlTreeNode BuildHql(MethodInfo method, Expression targetObject, ReadOnlyCollection<Expression> arguments, HqlTreeBuilder treeBuilder, IHqlExpressionVisitor visitor) { // All has two arguments. Arg 1 is the source and arg 2 is the predicate var predicate = (LambdaExpression) arguments[1]; return treeBuilder.BooleanNot( treeBuilder.Exists( treeBuilder.Query( treeBuilder.SelectFrom( treeBuilder.From( treeBuilder.Range( visitor.Visit(arguments[0]), treeBuilder.Alias(predicate.Parameters[0].Name)) ) ), treeBuilder.Where( treeBuilder.BooleanNot(visitor.Visit(arguments[1]).AsBooleanExpression()) ) ) ) ); }
public override HqlTreeNode BuildHql(MethodInfo method, Expression targetObject, ReadOnlyCollection<Expression> arguments, HqlTreeBuilder treeBuilder, IHqlExpressionVisitor visitor) { HqlAlias alias = null; HqlWhere where = null; if (arguments.Count > 1) { var expr = (LambdaExpression) arguments[1]; alias = treeBuilder.Alias(expr.Parameters[0].Name); where = treeBuilder.Where(visitor.Visit(arguments[1]).AsExpression()); } return treeBuilder.Exists( treeBuilder.Query( treeBuilder.SelectFrom( treeBuilder.From( treeBuilder.Range( visitor.Visit(arguments[0]), alias) ) ), where)); }
public IntermediateHqlTree(bool root) { _isRoot = root; TreeBuilder = new HqlTreeBuilder(); _root = TreeBuilder.Query(TreeBuilder.SelectFrom(TreeBuilder.From())); }
public override HqlTreeNode BuildHql(MethodInfo method, Expression targetObject, ReadOnlyCollection<Expression> arguments, HqlTreeBuilder treeBuilder, IHqlExpressionVisitor visitor) { // TODO - alias generator HqlAlias alias = treeBuilder.Alias("x"); ParameterExpression param = Expression.Parameter(targetObject.Type, "x"); HqlWhere where = treeBuilder.Where(visitor.Visit(Expression.Lambda( Expression.Equal(param, arguments[0]), param)) .AsExpression()); return treeBuilder.Exists( treeBuilder.Query( treeBuilder.SelectFrom( treeBuilder.From( treeBuilder.Range( visitor.Visit(targetObject), alias) ) ), where)); }