public string GetFieldAttribute() { if (IsPrimaryKey()) { return("[PrimaryKey(\"" + Column_Name + "\", Access = PropertyAccess.NosetterLowercaseUnderscore)]"); } else if (IsForeignKey()) { return("[BelongsTo(\"" + Column_Name + "\", Type = typeof(" + GetPropertyName() + "), Access = PropertyAccess.NosetterCamelcaseUnderscore)]"); } else { //FUTURE: if column name is reserved, add a back-tick, like "`User`" string prop = "[Property(\"" + Column_Name + "\", Access = PropertyAccess.NosetterCamelcaseUnderscore"; if (!Is_Nullable) { prop = prop + ", NotNull = true"; } if ( (Data_Type.Equals("text")) || (Data_Type.Equals("ntext")) ) { prop += ", ColumnType = \"StringClob\")]"; } else if (GetNetType().Equals("string") && Character_Maximum_Length > 1) { prop += ", Length = " + Character_Maximum_Length.ToString() + ")"; if (EnableValidationAttributes) { prop += ", ValidateLength(1, " + Character_Maximum_Length.ToString() + ")]"; } else { prop += "]"; } } else { prop += ")]"; } return(prop); } }
public string GetSqlType() { if ((Data_Type.Equals("bigint")) || (Data_Type.Equals("int")) || (Data_Type.Equals("smallint")) || (Data_Type.Equals("tinyint")) || (Data_Type.Equals("bit")) || (Data_Type.Equals("datetime")) || (Data_Type.Equals("smalldatetime")) || (Data_Type.Equals("money")) || (Data_Type.Equals("smallmoney")) || (Data_Type.Equals("float")) || (Data_Type.Equals("real")) || (Data_Type.Equals("ntext")) || (Data_Type.Equals("text")) || (Data_Type.Equals("image")) || (Data_Type.Equals("uniqueidentifier")) ) { return(Data_Type); } if ((Data_Type.Equals("char")) || (Data_Type.Equals("varchar")) || (Data_Type.Equals("nchar")) || (Data_Type.Equals("nvarchar")) || (Data_Type.Equals("binary")) || (Data_Type.Equals("varbinary")) ) { return(String.Format("{0}({1})", Data_Type, Character_Maximum_Length)); } if ((Data_Type.Equals("decimal")) || (Data_Type.Equals("numeric")) ) { return(String.Format("{0}({1},{2})", Data_Type, Numeric_Scale, Numeric_Precision)); } throw new Exception("Unexpected data type: " + Data_Type); }