public override HqlTreeNode BuildHql(
            MethodInfo method,
            Expression targetObject,
            ReadOnlyCollection<Expression> arguments,
            HqlTreeBuilder treeBuilder,
            IHqlExpressionVisitor visitor)
        {
            // Get the StringComparison argument.
            var comparison = (StringComparison)(arguments[1].As<ConstantExpression>().Value);

            if (comparison == StringComparison.CurrentCultureIgnoreCase
                || comparison == StringComparison.InvariantCultureIgnoreCase
                || comparison == StringComparison.OrdinalIgnoreCase)
            {
                // If the comparison calls for us to ignore the case, use SQL LOWER()
                return
                    treeBuilder.Equality(
                        treeBuilder.MethodCall("lower", new[] { visitor.Visit(targetObject).AsExpression() }),
                        treeBuilder.MethodCall("lower", new[] { visitor.Visit(arguments[0]).AsExpression() }));
            }

            // Otherwise use the database's default string comparison mechanism.
            return treeBuilder.Equality(
                visitor.Visit(targetObject).AsExpression(),
                visitor.Visit(arguments[0]).AsExpression());
        }
 public override HqlTreeNode BuildHql(MethodInfo method, Expression targetObject, ReadOnlyCollection<Expression> arguments, HqlTreeBuilder treeBuilder, IHqlExpressionVisitor visitor)
 {
     HqlExpression targetExpression = visitor.Visit(targetObject).AsExpression();
     HqlExpression argument0Expression = visitor.Visit(arguments[0]).AsExpression();
     HqlEquality result = treeBuilder.Equality(targetExpression, argument0Expression);
     return result;
 }
Beispiel #3
0
        public override HqlTreeNode BuildHql(
            MethodInfo method,
            Expression targetObject,
            ReadOnlyCollection <Expression> arguments,
            HqlTreeBuilder treeBuilder,
            IHqlExpressionVisitor visitor)
        {
            // Get the StringComparison argument.
            var comparison = (StringComparison)(arguments[1].As <ConstantExpression>().Value);

            if (comparison == StringComparison.CurrentCultureIgnoreCase ||
                comparison == StringComparison.InvariantCultureIgnoreCase ||
                comparison == StringComparison.OrdinalIgnoreCase)
            {
                // If the comparison calls for us to ignore the case, use SQL LOWER()
                return
                    (treeBuilder.Equality(
                         treeBuilder.MethodCall("lower", new[] { visitor.Visit(targetObject).AsExpression() }),
                         treeBuilder.MethodCall("lower", new[] { visitor.Visit(arguments[0]).AsExpression() })));
            }

            // Otherwise use the database's default string comparison mechanism.
            return(treeBuilder.Equality(
                       visitor.Visit(targetObject).AsExpression(),
                       visitor.Visit(arguments[0]).AsExpression()));
        }
		public HqlTreeNode BuildHql(MethodInfo method, Expression targetObject, ReadOnlyCollection<Expression> arguments,
		                            HqlTreeBuilder treeBuilder, IHqlExpressionVisitor visitor)
		{
			return treeBuilder.Like(
				visitor.Visit(arguments[0]).AsExpression(),
				visitor.Visit(arguments[1]).AsExpression());
		}
 public override HqlTreeNode BuildHql(System.Reflection.MethodInfo method, Expression targetObject, System.Collections.ObjectModel.ReadOnlyCollection <Expression> arguments,
                                      HqlTreeBuilder treeBuilder, IHqlExpressionVisitor visitor)
 {
     return(treeBuilder.LessThan(
                visitor.Visit(arguments[0]).AsExpression(),
                visitor.Visit(arguments[1]).AsExpression()));
 }
 public override HqlTreeNode BuildHql(MethodInfo method,
                                      Expression targetObject,
                                      ReadOnlyCollection <Expression> arguments,
                                      HqlTreeBuilder treeBuilder,
                                      IHqlExpressionVisitor visitor)
 {
     return(treeBuilder.Cast(visitor.Visit(arguments[0]).AsExpression(), typeof(Int64)));
 }
Beispiel #7
0
 public override HqlTreeNode BuildHql(
     MemberInfo member,
     Expression expression,
     HqlTreeBuilder treeBuilder,
     IHqlExpressionVisitor visitor)
 {
     return(treeBuilder.MethodCall(_hqlFunctions[member]));
 }
		public override HqlTreeNode BuildHql(MethodInfo method, Expression targetObject, ReadOnlyCollection<Expression> arguments, HqlTreeBuilder treeBuilder, IHqlExpressionVisitor visitor)
		{
			IEnumerable<HqlExpression> args = visitor.Visit(targetObject)
				.Union(arguments.Select(a => visitor.Visit(a)))
				.Cast<HqlExpression>();

			return treeBuilder.MethodCall(_name, args);
		}
Beispiel #9
0
 public override HqlTreeNode BuildHql(MethodInfo method, Expression targetObject, ReadOnlyCollection<Expression> arguments, HqlTreeBuilder treeBuilder, IHqlExpressionVisitor visitor)
 {
     return treeBuilder.Like(
         visitor.Visit(targetObject).AsExpression(),
         treeBuilder.Concat(
             treeBuilder.Constant("%"),
             visitor.Visit(arguments[0]).AsExpression()));
 }
        public override HqlTreeNode BuildHql(MethodInfo method, Expression targetObject,
                                             ReadOnlyCollection<Expression> arguments, HqlTreeBuilder treeBuilder,
                                             IHqlExpressionVisitor visitor)
        {
            var arg = visitor.Visit(arguments[0]).AsExpression();
            var mt = treeBuilder.MethodCall("hid_Parse", arg);

            return mt;
        }
		public override HqlTreeNode BuildHql(MethodInfo method, Expression targetObject,
		                                     ReadOnlyCollection<Expression> arguments, HqlTreeBuilder treeBuilder,
		                                     IHqlExpressionVisitor visitor)
		{
			IEnumerable<HqlExpression> args = arguments.Select(a => visitor.Visit(a))
				.Cast<HqlExpression>();

			return treeBuilder.BooleanMethodCall("FREETEXT", args);
		}
		public override HqlTreeNode BuildHql(MethodInfo method, Expression targetObject, ReadOnlyCollection<Expression> arguments, HqlTreeBuilder treeBuilder, IHqlExpressionVisitor visitor)
		{
			// HqlGeneratorExpressionTreeVisitor.VisitConstantExpression will always return an HqlEquality 
			// instead of HqlParameter for argument that is of type bool.
			// Use the HqlParameter that exists as first children to the HqlEquality as second argument into treeBuilder.Equality
			return treeBuilder.Equality(
				visitor.Visit(targetObject).AsExpression(),
				visitor.Visit(arguments[0]).Children.First().AsExpression());
		}
		private static HqlExpression GetRhs(MethodInfo method, ReadOnlyCollection<Expression> arguments, HqlTreeBuilder treeBuilder, IHqlExpressionVisitor visitor)
		{
			if (arguments.Count > 0)
				return visitor.Visit(arguments[0]).AsExpression();

			var returnType = method.ReturnType;
			var instance = returnType.IsValueType ? Activator.CreateInstance(returnType) : null;
			return treeBuilder.Constant(instance);
		}
Beispiel #14
0
 public override HqlTreeNode BuildHql(
     MethodInfo method,
     Expression targetObject,
     ReadOnlyCollection <Expression> arguments,
     HqlTreeBuilder treeBuilder,
     IHqlExpressionVisitor visitor)
 {
     return(treeBuilder.MethodCall("new_uuid"));
 }
		public override HqlTreeNode BuildHql(MethodInfo method, Expression targetObject, ReadOnlyCollection<Expression> arguments, HqlTreeBuilder treeBuilder, IHqlExpressionVisitor visitor)
		{
			Expression lhs = arguments.Count == 1 ? targetObject : arguments[0];
			Expression rhs = arguments.Count == 1 ? arguments[0] : arguments[1];

			return treeBuilder.Equality(
				visitor.Visit(lhs).AsExpression(),
				visitor.Visit(rhs).AsExpression());
		}
        public override HqlTreeNode BuildHql(MethodInfo method, Expression targetObject, ReadOnlyCollection<Expression> arguments, HqlTreeBuilder treeBuilder, IHqlExpressionVisitor visitor)
        {
            var arg = visitor.Visit(arguments[0]).AsExpression();
            var c1 = visitor.Visit(arguments[1]).AsExpression();
            var c2 = visitor.Visit(arguments[2]).AsExpression();

            var mt = treeBuilder.MethodCall("hid_GetReparentedValue", arg, c1, c2);

            return mt;
        }
Beispiel #17
0
 public override HqlTreeNode BuildHql(MethodInfo method, Expression targetObject, ReadOnlyCollection<Expression> arguments, HqlTreeBuilder treeBuilder, IHqlExpressionVisitor visitor)
 {
     return treeBuilder.Concat(
         new[]
     {
         visitor.Visit(arguments[0]).AsExpression(),
         visitor.Visit(arguments[1]).AsExpression(),
         visitor.Visit(arguments[2]).AsExpression()
     });
 }
Beispiel #18
0
        public override HqlTreeNode BuildHql(MethodInfo method, Expression targetObjectExpr, ReadOnlyCollection <Expression> arguments,
                                             HqlTreeBuilder treeBuilder, IHqlExpressionVisitor visitor)
        {
            var exprs = McsGetStringLinqTranslator.TranslateParametersMcsGetString(method, targetObjectExpr, arguments);

            var         parameters = exprs.Select(e => visitor.Visit(e).AsExpression());
            HqlTreeNode result     = treeBuilder.MethodCall("mcs_get_string", parameters);

            return(result);
        }
        public override HqlTreeNode BuildHql(MethodInfo method, Expression targetObject,
                                             ReadOnlyCollection <Expression> arguments, HqlTreeBuilder treeBuilder,
                                             IHqlExpressionVisitor visitor)
        {
            var arg    = visitor.Visit(arguments[0]).AsExpression();
            var parent = visitor.Visit(arguments[1]).AsExpression();
            var mt     = treeBuilder.BooleanMethodCall("hid_IsDescendantOf", new[] { arg, parent });

            return(mt);
        }
        public override HqlTreeNode BuildHql(MethodInfo method, Expression targetObject,
                                             ReadOnlyCollection<Expression> arguments, HqlTreeBuilder treeBuilder,
                                             IHqlExpressionVisitor visitor)
        {
            var arg = visitor.Visit(arguments[0]).AsExpression();
            var parent = visitor.Visit(arguments[1]).AsExpression();
            var mt = treeBuilder.BooleanMethodCall("hid_IsDescendantOf", new[] {arg, parent});

            return mt;
        }
Beispiel #21
0
 public override HqlTreeNode BuildHql(
     MethodInfo method,
     Expression targetObject,
     ReadOnlyCollection <System.Linq.Expressions.Expression> arguments,
     HqlTreeBuilder treeBuilder,
     IHqlExpressionVisitor visitor)
 {
     return(treeBuilder.BooleanMethodCall(
                "similar to",
                arguments.Select(visitor.Visit).Cast <HqlExpression>()));
 }
Beispiel #22
0
		public override HqlTreeNode BuildHql(MethodInfo method, Expression targetObject, ReadOnlyCollection<Expression> arguments, HqlTreeBuilder treeBuilder, IHqlExpressionVisitor visitor)
		{
			string leadingOrTrailing = "TRAILING";
			if (method.Name == "TrimLeading")
				leadingOrTrailing = "LEADING";

			return treeBuilder.MethodCall("Trim",
										  treeBuilder.Ident(leadingOrTrailing),
			                              visitor.Visit(arguments[1]).AsExpression(),
										  treeBuilder.Ident("FROM"),
			                              visitor.Visit(arguments[0]).AsExpression());
		}
        public override HqlTreeNode BuildHql(MethodInfo method, Expression targetObject, ReadOnlyCollection<Expression> arguments, HqlTreeBuilder treeBuilder, IHqlExpressionVisitor visitor)
        {
            HqlExpression value = visitor.Visit(arguments[0]).AsExpression();
            HqlTreeNode inClauseNode = BuildInClause(arguments, treeBuilder, visitor);

            HqlTreeNode inClause = treeBuilder.In(value, inClauseNode);

            if (method.Name == "NotIn")
                inClause = treeBuilder.BooleanNot((HqlBooleanExpression)inClause);

            return inClause;
        }
Beispiel #24
0
		public override HqlTreeNode BuildHql(MethodInfo method, Expression expression, ReadOnlyCollection<Expression> arguments, HqlTreeBuilder treeBuilder, IHqlExpressionVisitor visitor)
		{
			string function = method.Name.ToLowerInvariant();
			HqlExpression firstArgument = visitor.Visit(arguments[0]).AsExpression();

			if (arguments.Count == 2)
			{
				return treeBuilder.MethodCall(function, firstArgument, visitor.Visit(arguments[1]).AsExpression());
			}

			return treeBuilder.MethodCall(function, firstArgument);
		}
        /// <summary>
        /// 
        /// </summary>
        /// <param name="method"></param>
        /// <param name="targetObject">Should be an ISecurable</param>
        /// <param name="arguments">Not sure what the heck arg[0] is, but arg[1] is the entityName</param>
        /// <param name="treeBuilder"></param>
        /// <param name="visitor"></param>
        /// <returns></returns>
        public override HqlTreeNode BuildHql(
            MethodInfo method,
            Expression targetObject,
            ReadOnlyCollection<Expression> arguments,
            HqlTreeBuilder treeBuilder,
            IHqlExpressionVisitor visitor)
        {
            // This works, but it pulls the entity into memory, which is not what we want.
            Expression<Func<ISecurable, string, bool>> IsAllowedExpression = (x, name) =>
                x.IsLoadableFor(name);

            return visitor.Visit(IsAllowedExpression);
        }
        public override HqlTreeNode BuildHql(MethodInfo method, Expression targetObject, ReadOnlyCollection<Expression> arguments, HqlTreeBuilder treeBuilder, IHqlExpressionVisitor visitor)
        {
            /*
            HqlDot hqlDot = (HqlDot)visitor.Visit(arguments[0]).AsExpression();
            List<HqlTreeNode> hqlTreeNodes = hqlDot.Children.ToList();

            FieldInfo fieldInfo = typeof(HqlTreeNode).GetField("_node", BindingFlags.NonPublic | BindingFlags.Instance);

            HqlIdent node1 = (HqlIdent)hqlTreeNodes[0];
            IASTNode tableNode = (IASTNode)fieldInfo.GetValue(node1);
            string tableText = tableNode.Text;

            HqlIdent node2 = (HqlIdent)hqlTreeNodes[1];
            IASTNode columnNode = (IASTNode)fieldInfo.GetValue(node2);
            string columnText = columnNode.Text;

            string format = string.Format("{0}.{1} (+)", tableText, columnText);

            //return treeBuilder.AnyValueConstant(format);
            return treeBuilder.AnyValueConstant("customer1_.ID (+)");
            */


            HqlAnyValueConstant expression0 = treeBuilder.AnyValueConstant("+");
            HqlExpression expression1 = visitor.Visit(arguments[0]).AsExpression();

            List<HqlExpression> expressions = new List<HqlExpression>();
            expressions.Add(expression0);
            expressions.Add(expression1);
            return treeBuilder.BooleanMethodCall("", expressions);



            //treeBuilder.Equality();
            //HqlMethodCall leftSign = treeBuilder.MethodCall("", treeBuilder.Plus());

            /*
            return expression2;

            HqlDot dot = (HqlDot) expression2;
            //return treeBuilder.AnyValueConstant(" ", expression1, expression2);
            return expression1;

            /*
            return expression2;
            */
            //return leftSign;
            //return treeBuilder.Space(leftSign, );
        }
        ///<summary>
        ///
        ///</summary>
        ///<param name="method"></param>
        ///<param name="targetObject">Should be an ISecurable</param>
        ///<param name="arguments">Not sure what the heck arg[0] is, but arg[1] is the entityName</param>
        ///<param name="treeBuilder"></param>
        ///<param name="visitor"></param>
        ///<returns></returns>
        public override HqlTreeNode BuildHql(
            MethodInfo method,
            Expression targetObject,
            ReadOnlyCollection<Expression> arguments,
            HqlTreeBuilder treeBuilder,
            IHqlExpressionVisitor visitor)
        {
            // arguments[0] is a System.Linq.Expressions.Expression
            // arguments[1] is our constant value
            var expr = arguments[0];

            // This doesn't really help us right now, but log it just in case...
            if (expr is Remotion.Linq.Clauses.Expressions.QuerySourceReferenceExpression)
            {
                Console.WriteLine(
                    "ReferencedQuerySource: {0}",
                    ((Remotion.Linq.Clauses.Expressions.QuerySourceReferenceExpression)expr).ReferencedQuerySource
                );
            }

            // Getting somewhere?
            // expr.Type is Spc.Ofp.Tubs.DAL.Entities.Trip
            Console.WriteLine("Expression type: {0}", expr.Type);

            // HqlAlias is "AccessControl" (entity property), "ace" (name used in expression) ?
            // HqlExpression is equality expression ?
            var aceAlias = treeBuilder.Alias("AccessControl as ace");

            var entityName = ((ConstantExpression)arguments[1]).Value;

            Console.WriteLine("entityName: {0}", entityName);

            var equality = treeBuilder.Equality(
                treeBuilder.Alias("ace.EntityName"),
                treeBuilder.Constant(entityName)
            );

            var joinExpression = treeBuilder.Join(equality, aceAlias);

            // This doesn't actually do anything...
            return visitor.Visit(expr).AsExpression();

            /*
             * var dc =
                DetachedCriteria.For<T>()
                                .CreateAlias("AccessControl", "ace", JoinType.InnerJoin)
                                .Add(NHibernate.Criterion.Expression.Eq("ace.EntityName", this._entityName));
             */
        }
		public override HqlTreeNode BuildHql(
			MethodInfo method,
			Expression targetObject,
			ReadOnlyCollection<Expression> arguments,
			HqlTreeBuilder treeBuilder,
			IHqlExpressionVisitor visitor)
		{
			var left = treeBuilder.Cast(visitor.Visit(targetObject).AsExpression(), typeof(string));
			var right = treeBuilder.Cast(visitor.Visit(arguments.First()).AsExpression(), typeof(string));

			var leftSubstring = treeBuilder.MethodCall("substring", left, treeBuilder.Constant(4));
			var rightSubstring = treeBuilder.MethodCall("substring", right, treeBuilder.Constant(4));
			var equals = treeBuilder.Equality(leftSubstring, rightSubstring);
			return equals;
		}
 public override HqlTreeNode BuildHql(MethodInfo method, Expression targetObject, ReadOnlyCollection<Expression> arguments, HqlTreeBuilder treeBuilder, IHqlExpressionVisitor visitor)
 {
     var comparison = (StringComparison)(arguments[1].As<ConstantExpression>().Value);
     if (comparison == StringComparison.CurrentCultureIgnoreCase ||
         comparison == StringComparison.InvariantCultureIgnoreCase ||
         comparison == StringComparison.OrdinalIgnoreCase)
     {
         return treeBuilder.Equality(
             treeBuilder.MethodCall("lower", new[] { visitor.Visit(targetObject).AsExpression() }),
             treeBuilder.MethodCall("lower", new[] { visitor.Visit(arguments[0]).AsExpression() }));
     }
     return treeBuilder.Equality(
         visitor.Visit(targetObject).AsExpression(),
         visitor.Visit(arguments[0]).AsExpression());
 }
    public override HqlTreeNode BuildHql(
        MethodInfo method,
        System.Linq.Expressions.Expression targetObject,
        ReadOnlyCollection <System.Linq.Expressions.Expression> arguments,
        HqlTreeBuilder treeBuilder, IHqlExpressionVisitor visitor)
    {
        // Is there a better way to do this?
        var               factory        = new ASTFactory(new ASTTreeAdaptor());
        HqlTreeNode       escapeCharNode = visitor.Visit(arguments[2]).AsExpression();
        var               escapeNode     = new HqlEscape(factory, escapeCharNode);
        HqlLikeWithEscape likeClauseNode =
            new HqlLikeWithEscape(
                factory,
                visitor.Visit(arguments[0]).AsExpression(),
                visitor.Visit(arguments[1]).AsExpression(),
                escapeNode);

        return(likeClauseNode);
    }
		public HqlTreeNode BuildHql(MethodInfo method, Expression targetObject, ReadOnlyCollection<Expression> arguments,
		                            HqlTreeBuilder treeBuilder, IHqlExpressionVisitor visitor)
		{
			if (arguments.Count == 2)
			{
				return treeBuilder.Like(
					visitor.Visit(arguments[0]).AsExpression(),
					visitor.Visit(arguments[1]).AsExpression());
			}
			if (arguments[2].NodeType == ExpressionType.Constant)
			{
				var escapeCharExpression = (ConstantExpression)arguments[2];
				return treeBuilder.Like(
					visitor.Visit(arguments[0]).AsExpression(),
					visitor.Visit(arguments[1]).AsExpression(),
					treeBuilder.Constant(escapeCharExpression.Value));
			}
			throw new ArgumentException("The escape character must be specified as literal value or a string variable");

		}
        private HqlTreeNode BuildInClause(ReadOnlyCollection<Expression> arguments, HqlTreeBuilder treeBuilder, IHqlExpressionVisitor visitor)
        {
            ConstantExpression constantExpression = arguments[1] as ConstantExpression;
            if (constantExpression == null)
            {
                HqlTreeNode result = BuildFromExpression(arguments[1], visitor);
                return result;
            }

            IEnumerable valueArray = (IEnumerable)constantExpression.Value;
            Type elementType = GetElementType(valueArray);

            if (elementType.IsValueType || elementType == typeof(string))
            {
                HqlTreeNode result = BuildFromArray(valueArray, treeBuilder, elementType);
                return result;
            }

            HqlTreeNode hqlTreeNode = BuildFromExpression(arguments[1], visitor);
            return hqlTreeNode;
        }
		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)
        {
            // There is a problem with NHibernate when an identifier matches an entity's name. The resulting
            // SQL may be null in that situation. The searchTable's name is split in 2 identifiers to mitigate the problem.
            string searchTable = (string)((ConstantExpression)arguments[2]).Value;
            var searchTableFullName = searchTable.Split('.');
            if (searchTableFullName.Length != 2)
                throw new FrameworkException("FullTextSearch table name '" + searchTable + "' must have format 'schema.table'.");

            string searchColumns = (string)((ConstantExpression)arguments[3]).Value;

            var parameters = new HqlExpression[]
            {
                visitor.Visit(arguments[0]).AsExpression(),
                visitor.Visit(arguments[1]).AsExpression(),
                treeBuilder.Ident(searchTableFullName[0]),
                treeBuilder.Ident(searchTableFullName[1]),
                treeBuilder.Ident(searchColumns),
            };

            return treeBuilder.BooleanMethodCall("FullTextSearch", parameters);
        }
Beispiel #35
0
		public override HqlTreeNode BuildHql(MethodInfo method, Expression targetObject, ReadOnlyCollection<Expression> arguments, HqlTreeBuilder treeBuilder, IHqlExpressionVisitor visitor)
		{
			// Instance CompareTo() or static string.Compare()?
			Expression lhs = arguments.Count == 1 ? targetObject : arguments[0];
			Expression rhs = arguments.Count == 1 ? arguments[0] : arguments[1];

			HqlExpression lhs1 = visitor.Visit(lhs).AsExpression();
			HqlExpression rhs1 = visitor.Visit(rhs).AsExpression();
			HqlExpression lhs2 = visitor.Visit(lhs).AsExpression();
			HqlExpression rhs2 = visitor.Visit(rhs).AsExpression();

			// CASE WHEN (table.[Name] = N'Foo') THEN 0
			//      WHEN (table.[Name] > N'Foo') THEN 1
			//      ELSE -1 END

			return treeBuilder.Case(
				new[]
					{
						treeBuilder.When(treeBuilder.Equality(lhs1, rhs1), treeBuilder.Constant(0)),
						treeBuilder.When(treeBuilder.GreaterThan(lhs2, rhs2), treeBuilder.Constant(1))
					},
				treeBuilder.Constant(-1));
		}
		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));
		}
Beispiel #37
0
 public override HqlTreeNode BuildHql(MemberInfo member, Expression expression, HqlTreeBuilder treeBuilder, IHqlExpressionVisitor visitor)
 {
     return treeBuilder.MethodCall("length", visitor.Visit(expression).AsExpression());
 }
Beispiel #38
0
 public override HqlTreeNode BuildHql(MethodInfo method, Expression targetObject, ReadOnlyCollection<Expression> arguments, HqlTreeBuilder treeBuilder, IHqlExpressionVisitor visitor)
 {
     return treeBuilder.MethodCall("replace",
                                   visitor.Visit(targetObject).AsExpression(),
                                   visitor.Visit(arguments[0]).AsExpression(),
                                   visitor.Visit(arguments[1]).AsExpression());
 }
Beispiel #39
0
 public override HqlTreeNode BuildHql(MethodInfo method, Expression targetObject, ReadOnlyCollection<Expression> arguments, HqlTreeBuilder treeBuilder, IHqlExpressionVisitor visitor)
 {
     if (arguments.Count == 1)
     {
         return treeBuilder.MethodCall("locate", 
             visitor.Visit(arguments[0]).AsExpression(),
             visitor.Visit(targetObject).AsExpression(),
             treeBuilder.Constant(0));
     }
     return treeBuilder.MethodCall("locate", 
         visitor.Visit(arguments[0]).AsExpression(),
         visitor.Visit(targetObject).AsExpression(),
         visitor.Visit(arguments[1]).AsExpression());
 }