Ejemplo n.º 1
0
 public virtual void Visit(FunctionExpression op)
 {
     if (op is Functions.CurrentDateTime || op is Functions.CurrentUtcDateTime)
     {
         Writer.Write("getutcdate()");
     }
     else
     {
         throw new NotSupportedException();
     }
 }
Ejemplo n.º 2
0
 void IExpressionVisitor.Visit(FunctionExpression op)
 {
     _clone = op.Clone(CloneAndReturn);
 }
Ejemplo n.º 3
0
 void IExpressionVisitor.Visit(FunctionExpression op)
 {
     throw new NotSupportedException();
 }
Ejemplo n.º 4
0
        public void Visit(FunctionExpression op)
        {
            var name = op.Name.ToLowerInvariant();

            switch (name)
            {
            case "length":
            case "tolower":
            case "toupper":
            case "trim":
            case "day":
            case "hour":
            case "minute":
            case "month":
            case "second":
            case "year":
            case "ceiling":
            case "floor":
            case "startswith":
            case "endswith":
            case "contains":
                // Do nothing
                break;

            case "round":
                if (!(op.Args.Skip(1).First() is IntegerLiteral iLit && iLit.Value == 0))
                {
                    throw new NotSupportedException();
                }
                break;

            case "indexof_zero":
                name = "indexof";
                break;

            case "substring_zero":
                name = "substring";
                break;

            case "truncatetime":
                name = "date";
                break;

            case "currentdatetime":
            case "currentutcdatetime":
                name = "now";
                break;

            default:
                op.Evaluate().Visit(this);
                return;
            }

            WriteEncoded(name);
            WriteEncoded("(");
            var first = true;

            foreach (var arg in op.Args)
            {
                if (!first)
                {
                    WriteEncoded(",");
                }
                first = false;
                arg.Visit(this);
            }
            WriteEncoded(")");
        }