/// <summary> /// Détermine le nom du type T-SQL avec la précision. /// </summary> /// <param name="property">Propriété de classe.</param> /// <returns>Nom du type T-SQL.</returns> public static string DeterminerSqlDataType(this ModelProperty property) { if (property == null) { throw new ArgumentNullException("property"); } IPersistenceData persistenceData = property.IsDatabaseOnly ? property.DataMember : // Propriété non applicative : les données de persistence sont portées par le champ directement. (IPersistenceData)property.DataDescription.Domain; // Propriété applicative : les données de persistences sont portées par le domaine. string persistentType = CodeUtils.PowerDesignerPersistentDataTypeToSqlDatType(persistenceData.PersistentDataType); bool hasLength = persistenceData.PersistentLength.HasValue; bool hasPrecision = persistenceData.PersistentPrecision.HasValue; if (hasLength) { persistentType += "(" + persistenceData.PersistentLength; if (hasPrecision) { persistentType += "," + persistenceData.PersistentPrecision; } persistentType += ")"; } else if (property.DataDescription.IsPrimaryKey && property.DataDescription.Domain.Code == "DO_ID") { persistentType += " identity"; } return(persistentType); }
/// <summary> /// Détermine le nom du type T-SQL avec la précision. /// </summary> /// <param name="property">Propriété de classe.</param> /// <returns>Nom du type T-SQL.</returns> public static string DeterminerSqlDataType(this ModelProperty property) { if (property == null) { throw new ArgumentNullException("property"); } IPersistenceData persistenceData = property.IsDatabaseOnly ? property.DataMember : // Propriété non applicative : les données de persistence sont portées par le champ directement. (IPersistenceData)property.DataDescription.Domain; // Propriété applicative : les données de persistences sont portées par le domaine. var persistentType = persistenceData.PersistentDataType; if (property.DataDescription.IsPrimaryKey && property.DataDescription.Domain.Code == "DO_ID") { persistentType += " identity"; } else if (persistentType == "nvarchar") { persistentType += "(MAX)"; } return(persistentType); }