public virtual void Visit(FunctionExpression op) { if (op is Functions.CurrentDateTime || op is Functions.CurrentUtcDateTime) { Writer.Write("getutcdate()"); } else { throw new NotSupportedException(); } }
void IExpressionVisitor.Visit(FunctionExpression op) { _clone = op.Clone(CloneAndReturn); }
void IExpressionVisitor.Visit(FunctionExpression op) { throw new NotSupportedException(); }
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(")"); }