protected internal 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); }
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 { sb.Append(c.ToString()); } } return(c); }
protected internal virtual Expression VisitSqlConstant(SqlConstantExpression sce) { return(sce); }
protected virtual bool CompareSqlConstant(SqlConstantExpression a, SqlConstantExpression b) { return(object.Equals(a.Value, b.Value)); }
protected internal override Expression VisitSqlConstant(SqlConstantExpression sce) { return(Expression.Constant(sce.Value, sce.Type)); }