protected string GetNullableTypeName(DbColumnInfo info) { string s = GetTypeName(info.DataType); if(info.AllowDBNull && info.DataType.IsValueType) { s += "?"; } return s; }
protected virtual void BuildColumn(DbColumnInfo info) { Result.Append("\t"); if(info.AllowDBNull && !info.DataType.IsValueType) { Result.Append("[AllowNull] "); } if(info.DataType == typeof(string) || info.DataType == typeof(byte[])) { if (info.ColumnSize < 32768) { Result.Append("[Length(").Append(info.ColumnSize).Append(")] "); } } if(info.IsUnique) { Result.Append("[Index(UNIQUE = true)] "); } Result.Append("public "); Result.Append(GetNullableTypeName(info)); Result.Append(" "); Result.Append(info.ColumnName); Result.Append(GetColumnBody()); Result.Append("\r\n"); }
protected virtual void BuildKeyColomn(DbColumnInfo info) { }
protected override void ProcessColumn(DbColumnInfo info) { base.ProcessColumn(info); InitMethodBody.Append("\t\tthis."); InitMethodBody.Append(info.ColumnName); InitMethodBody.Append(" = "); InitMethodBody.Append(info.ColumnName); InitMethodBody.Append(";\r\n"); }
protected override void ProcessKeyColumn(DbColumnInfo info) { if(!info.IsAutoIncrement) { ProcessColumn(info); } }
protected override void BuildKeyColomn(DbColumnInfo info) { Result.Append(info.IsAutoIncrement ? "\t[DbKey]\r\n" : "\t[DbKey(IsDbGenerate = false)]\r\n"); BuildColumn(info); }
protected virtual void ProcessColumn(DbColumnInfo info) { }