示例#1
0
        public Expression IndexOfMethod(IndexOfMethod method, LiteralExpression[] arguments)
        {
            int result;

            if (LiteralUtil.IsAnyNull(arguments))
            {
                result = -1;
            }
            else
            {
                result = LiteralUtil.CoerceString(arguments[0]).IndexOf(
                    LiteralUtil.CoerceString(arguments[1]),
                    StringComparison.InvariantCultureIgnoreCase
                    );
            }

            if (result == -1)
            {
                return(new LiteralExpression(null, LiteralType.Null));
            }
            else
            {
                return(new LiteralExpression(result + 1, LiteralType.Int));
            }
        }
示例#2
0
        public override IProjection IndexOfMethod(IndexOfMethod method, Expression[] arguments)
        {
            // The standard registered locate function expects three parameters,
            // and the rest seems tot support it.

            return(new SqlFunctionProjection(
                       "locate",
                       NHibernateUtil.Int32,
                       ProjectionVisitor.CreateProjection(arguments[1]),
                       ProjectionVisitor.CreateProjection(arguments[0]),
                       Projections.Constant(1)
                       ));
        }
 public virtual TResult IndexOfMethod(IndexOfMethod method, Expression[] arguments)
 {
     throw new QueryNotSupportException();
 }