protected internal override Expression VisitSqlConstant(SqlConstantExpression c) { if (c.Value == null) { sb.Append("NULL"); } else { if (!schema.Settings.IsDbType(c.Value.GetType().UnNullify())) { throw new NotSupportedException(string.Format("The constant for {0} is not supported", c.Value)); } if (!isPostgres && c.Value.Equals(true)) { sb.Append('1'); } else if (!isPostgres && c.Value.Equals(false)) { sb.Append('0'); } else if (c.Value is string s) { sb.Append(s == "" ? "''" : ("'" + s + "'")); } else if (c.Value is TimeSpan ts) { sb.Append(@$ "CONVERT(time, '{ts}')"); } else if (ReflectionTools.IsDecimalNumber(c.Value.GetType())) { sb.Append(((IFormattable)c.Value).ToString("0.00####", CultureInfo.InvariantCulture)); } else { sb.Append(c.ToString()); } } return(c); }
protected override Expression VisitSqlConstant(SqlConstantExpression c) { if (c.Value == null) sb.Append("NULL"); else { if (!Schema.Current.Settings.IsDbType(c.Value.GetType().UnNullify())) throw new NotSupportedException(string.Format("The constant for {0} is not supported", c.Value)); if (c.Value.Equals(true)) sb.Append("1"); else if (c.Value.Equals(false)) sb.Append("0"); else if (c.Value is string) sb.Append(((string)c.Value == "") ? "''" : ("'" + c.Value + "'")); else sb.Append(c.ToString()); } return c; }