public override void VisitTableColumn(TableColumnCommand cmd) { this.AppendFormat("{0} ", cmd.Name); this.VisitDbType(cmd); if (cmd.IsIdentity.HasValue && cmd.IsIdentity.Value) { this.Append("NOT NULL "); this.Append("IDENTITY(1,1) "); } else { if (cmd.Default != null) { this.Append("NOT NULL "); this.AppendFormat("DEFAULT '{0}' ", cmd.Default.ToString()); } else { if (cmd.IsNotNull.HasValue && cmd.IsNotNull.Value) { this.Append("NOT NULL "); } else { this.Append("NULL "); } } } }
public override void VisitDbType(TableColumnCommand cmd) { if (!cmd.DbType.HasValue) return; switch (cmd.DbType) { case DbType.AnsiString: this.AppendFormat("LONG RAW "); break; case DbType.AnsiStringFixedLength: this.AppendFormat("CHAR({0}) ", cmd.Length ?? 50); break; case DbType.Binary: this.Append("LONG RAW "); break; case DbType.Boolean: this.Append("NUMBER(1) "); break; case DbType.Byte: this.Append("BLOB "); break; case DbType.Currency: this.AppendFormat("NCHAR({0}) ", cmd.Length ?? 9); break; case DbType.Date: this.Append("DATE "); break; case DbType.DateTime: this.Append("DATE "); break; case DbType.DateTime2: this.Append("DATETIME "); break; case DbType.DateTimeOffset: this.Append("DATETIME "); break; case DbType.Decimal: this.AppendFormat("FLOAT({0},{1}) ", cmd.Length ?? 0, cmd.Scale); break; case DbType.Double: this.Append("FLOAT "); break; case DbType.Guid: this.Append("RAW(16) "); break; case DbType.Int16: case DbType.UInt16: this.Append("INTEGER "); break; case DbType.Int32: case DbType.UInt32: this.Append("INTEGER "); break; case DbType.Int64: case DbType.UInt64: this.Append("INTEGER "); break; case DbType.Object: this.Append("INTERVAL DAY TO SECOND "); break; case DbType.SByte: this.Append("TINYINT "); break; case DbType.Single: this.Append("FLOAT "); break; case DbType.String: this.AppendFormat("NVARCHAR2({0}) ", cmd.Length ?? 50); break; case DbType.StringFixedLength: this.AppendFormat("NCHAR({0}) ", cmd.Length ?? 50); break; case DbType.Time: this.Append("TIMESTAMP "); break; case DbType.VarNumeric: this.AppendFormat("NUMBER({0}) ", cmd.Length ?? 50); break; case DbType.Xml: this.Append("LONG RAW "); break; default: break; } }
public virtual void VisitDbType(TableColumnCommand cmd) { if (!cmd.DbType.HasValue) return; switch (cmd.DbType) { case DbType.AnsiString: this.AppendFormat("TEXT "); break; case DbType.AnsiStringFixedLength: this.AppendFormat("VARCHAR({0}) ", cmd.Length ?? 50); break; case DbType.Binary: this.Append("BINARY "); break; case DbType.Boolean: this.Append("BIT "); break; case DbType.Byte: this.Append("TINYINT "); break; case DbType.Currency: this.AppendFormat("MONEY({0}) ", cmd.Length ?? 9); break; case DbType.Date: this.Append("DATE "); break; case DbType.DateTime: this.Append("DATETIME "); break; case DbType.DateTime2: this.Append("DATETIME "); break; case DbType.DateTimeOffset: this.Append("DATETIME "); break; case DbType.Decimal: this.AppendFormat("DECIMAL({0},{1}) ", cmd.Length ?? 0, cmd.Scale); break; case DbType.Double: this.Append("FLOAT "); break; case DbType.Guid: this.Append("UNIQUEIDENTIFIER "); break; case DbType.Int16: case DbType.UInt16: this.Append("INT "); break; case DbType.Int32: case DbType.UInt32: this.Append("INT "); break; case DbType.Int64: case DbType.UInt64: this.Append("INT "); break; case DbType.Object: this.Append("SQL_VARIANT "); break; case DbType.SByte: this.Append("TINYINT "); break; case DbType.Single: this.Append("REAL "); break; case DbType.String: this.AppendFormat("NVARCHAR({0}) ", cmd.Length ?? 50); break; case DbType.StringFixedLength: this.AppendFormat("NCHAR({0}) ", cmd.Length ?? 50); break; case DbType.Time: this.Append("TIME "); break; case DbType.VarNumeric: this.AppendFormat("NUMERIC({0}) ", cmd.Length ?? 50); break; case DbType.Xml: this.Append("SQL_VARIANT "); break; default: break; } }