/// <summary> /// Devuelve el schema de la columna en formato SQL. /// </summary> public string ToSql(Boolean sqlConstraint) { string sql = ""; sql += "[" + Name + "] "; if (!IsComputed) { if (this.IsUserDefinedType) sql += Type; else sql += "[" + Type + "]"; if (Type.Equals("binary") || Type.Equals("varbinary") || Type.Equals("varchar") || Type.Equals("char") || Type.Equals("nchar") || Type.Equals("nvarchar")) { if (Size == -1) sql += " (max)"; else { if (Type.Equals("nchar") || Type.Equals("nvarchar")) sql += " (" + (Size / 2).ToString(CultureInfo.InvariantCulture) + ")"; else sql += " (" + Size.ToString(CultureInfo.InvariantCulture) + ")"; } } if (Type.Equals("xml")) { if (!String.IsNullOrEmpty(XmlSchema)) { if (IsXmlDocument) sql += "(DOCUMENT " + XmlSchema + ")"; else sql += "(CONTENT " + XmlSchema + ")"; } } if (Type.Equals("numeric") || Type.Equals("decimal")) sql += " (" + Precision.ToString(CultureInfo.InvariantCulture) + "," + Scale.ToString(CultureInfo.InvariantCulture) + ")"; if (((Database)Parent.Parent).Info.Version >= DatabaseInfo.VersionTypeEnum.SQLServer2008) { if (Type.Equals("datetime2") || Type.Equals("datetimeoffset") || Type.Equals("time")) sql += "(" + Scale.ToString(CultureInfo.InvariantCulture) + ")"; } if ((!String.IsNullOrEmpty(Collation)) && (!IsUserDefinedType)) sql += " COLLATE " + Collation; if (IsIdentity) sql += " IDENTITY (" + IdentitySeed.ToString(CultureInfo.InvariantCulture) + "," + IdentityIncrement.ToString(CultureInfo.InvariantCulture) + ")"; if (IsIdentityForReplication) sql += " NOT FOR REPLICATION"; if (IsSparse) sql += " SPARSE"; if (IsFileStream) sql += " FILESTREAM"; if (IsNullable) sql += " NULL"; else sql += " NOT NULL"; if (IsRowGuid) sql += " ROWGUIDCOL"; } else { sql += "AS " + ComputedFormula; if (IsPersisted) sql += " PERSISTED"; } if ((sqlConstraint) && (DefaultConstraint != null)) { if (DefaultConstraint.Status != ObjectStatus.Drop) sql += " " + DefaultConstraint.ToSql().Replace("\t", "").Trim(); } return sql; }
/// <summary> /// Devuelve el schema de la columna en formato SQL. /// </summary> public string ToSQL(Boolean sqlConstraint) { string sql = ""; sql += "\t[" + Name + "] "; if (!IsComputed) { sql += "[" + Type + "]"; if (Type.Equals("varbinary") || Type.Equals("varchar") || Type.Equals("char") || Type.Equals("nchar") || Type.Equals("nvarchar")) { sql += " (" + Size.ToString() + ")"; } if (Type.Equals("numeric") || Type.Equals("decimal")) { sql += " (" + Precision.ToString() + "," + Scale.ToString() + ")"; } if (!String.IsNullOrEmpty(Collation)) { sql += " COLLATE " + Collation; } if (Identity) { sql += " IDENTITY (" + IdentitySeed.ToString() + "," + IdentityIncrement.ToString() + ")"; } if (IdentityForReplication) { sql += " NOT FOR REPLICATION"; } if (Nullable) { sql += " NULL"; } else { sql += " NOT NULL"; } if (IsRowGuid) { sql += " ROWGUIDCOL"; } } else { sql += "AS " + computedFormula; } if ((sqlConstraint) && (constraints.Count > 0)) { sql += " " + constraints.ToSQL(); } return(sql); }
public override DbTypeBase ToGenericType() { DbTypeNumeric res = new DbTypeNumeric(); res.Precision = Precision; res.Scale = Scale; if (IsIdentity) { res.Autoincrement = true; res.SetSpecificAttribute("effiproz", "identity_increment", IdentityIncrement.ToString()); res.SetSpecificAttribute("effiproz", "identity_seed", IdentitySeed.ToString()); } return(res); }
public override DbTypeBase ToGenericType() { DbTypeInt res = new DbTypeInt(); res.Bytes = Bytes; res.Unsigned = false; if (IsIdentity) { res.Autoincrement = true; res.SetSpecificAttribute("effiproz", "identity_increment", IdentityIncrement.ToString()); res.SetSpecificAttribute("effiproz", "identity_seed", IdentitySeed.ToString()); } return(res); }