public override string ToSql(ExpressionSqlBuilder builder) { StringBuilder sb = new StringBuilder(); sb.Append(builder.EncodeTable(Name)); if (AlterColumn == AlterColumnType.AddColumn || AlterColumn == AlterColumnType.AlterColumn) { sb.Append(" "); if (builder.DbType == DriverType.PostgreSQL && AutoIncrement) { if (Type.Type == DbColumnType.BigInt) { sb.Append("bigserial"); } else { sb.Append("serial"); } } else { sb.Append(Type.ToSql(builder)); } if (AutoIncrement && builder.DbType == DriverType.SqlServer) { sb.Append(" IDENTITY(1,1)"); } if (Nullable) { sb.Append(" NULL"); } else { sb.Append(" NOT NULL"); } if (PrimaryKey) { sb.Append(" PRIMARY KEY"); } } return(sb.ToString()); }
public override string ToSql(ExpressionSqlBuilder builder) { return("cast(" + Operand.ToSql(builder) + " as " + ToType.ToSql(builder) + ")"); }