コード例 #1
0
ファイル: TSqlVisitor.cs プロジェクト: w0lya/sharpql
 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(")");
 }
コード例 #2
0
 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(")");
 }