Exemplo n.º 1
0
 public static void ConvertTimeSpanToSql_SqlServer(this StringBuilder stringBuilder, SqlDataType sqlDataType, TimeSpan value)
 {
     if (sqlDataType.Type.DataType == DataType.Int64)
     {
         stringBuilder.Append(value.Ticks);
     }
     else
     {
         var format = value.Days > 0
   ? DateTimeConstants.TimeSpanFormat(value.Ticks % 10000000 != 0 ? 7 : 0)
   : DateTimeConstants.SqlTimeFormat(value.Ticks % 10000000 != 0 ? 7 : 0);
         stringBuilder.AppendFormat(CultureInfo.InvariantCulture, format, value);
     }
 }
Exemplo n.º 2
0
 public static string ToSqlTime(this TimeSpan ts, int milliSecondsPrecision = 0) => ts.ToString(DateTimeConstants.SqlTimeFormat(milliSecondsPrecision));