public void DateAddFunction(SqlFragment parent, DateAddFunction dateAddFunction) { this.Script.Append("DATEADD("); this.Script.Append(dateAddFunction.DatePart.ToString()); this.Script.Append(", "); this.Script.AppendFragment(dateAddFunction.Number, dateAddFunction, this); this.Script.Append(", "); this.Script.AppendFragment(dateAddFunction.Date, dateAddFunction, this); this.Script.Append(")"); }
protected override void VisitDateAddFunction(DateAddFunction function) { // HACK: This may lose precision, like if you want to add days but keep the time! if (function.DatePart == DatePart.Hour || function.DatePart == DatePart.Minute || function.DatePart == DatePart.Second || function.DatePart == DatePart.Millisecond) { this.CommandText.Append("DATETIME("); } else { this.CommandText.Append("DATE("); } this.VisitField(function.Argument); this.CommandText.Append(", "); this.VisitField(function.Number); this.CommandText.Append(" || ' "); this.CommandText.Append(function.DatePart.ToString().ToLowerInvariant()); this.CommandText.Append("'"); this.CommandText.Append(")"); }