private EntityFieldInfo GetFieldInfo(string code) { // replace all white space with pipes string[] parts = Regex.Replace(code, @" +", "|").Split('|'); EntityFieldInfo info = new EntityFieldInfo(); info.FieldName = parts[2]; info.DataType = parts[1]; return(info); }
public static string getDBDataType(EntityFieldInfo field) { switch (field.DataType) { case DataTypes.String: string length = field.MaxLength > 0 ? field.MaxLength.ToString() : "max"; return($"varchar({length})"); case DataTypes.Decimal: return($"decimal({field.MaxLength}, {field.Scale})"); default: return(field.DataType); } }
public static string GetColumnDef(EntityFieldInfo fieldInfo) { var dt = DataTypeMapper.getDBDataType(fieldInfo); var def = $"[{fieldInfo.FieldName}] {dt}"; if (fieldInfo.IsIdentity) { def += " IDENTITY(1,1)"; } if (fieldInfo.IsRequired) { def += " NOT NULL"; } else { def += " NULL"; } return(def); }