public PDMDbProperty(string title, string code, string comment , bool isPrimaryKey, PDMDataType type, int length, int precision, bool nullable, bool isKeyWord) { Title = title; Code = code; Comment = comment; IsPrimaryKey = isPrimaryKey; Type = type; Length = length; Precision = precision; Nullable = nullable; IsKeyWord = isKeyWord; }
public PDMDbProperty(string title, string code, string comment , bool isPrimaryKey, PDMDataType type, int length, int precision, bool nullable) { this.Title = title; this.Code = code; this.Comment = comment; this.IsPrimaryKey = isPrimaryKey; //this.Type = type; this.Type = type; this.Length = length; this.Precision = precision; this.Nullable = nullable; }
public static string GetCSharpDataType(this Column column) { PDMDataType pdmDataType = column.GetPDMDataType(); int length = column.Length; int precision = column.Precision; switch (pdmDataType) { case PDMDataType.varchar: case PDMDataType.nvarchar: case PDMDataType.text: return(nameof(String)); case PDMDataType.numeric: if (precision > 0) { return(nameof(Decimal)); } if (length > 32) { return(nameof(Int64)); } else if (length > 16 || length == 0) { return(nameof(Int32)); } else if (length > 1) { return(nameof(Int16)); } else { return(nameof(Boolean)); } case PDMDataType.datetime: return(nameof(DateTime)); case PDMDataType.uniqueidentifier: return(nameof(Guid)); case PDMDataType.boolean: return(nameof(Boolean)); default: throw new NotImplementedException(string.Format("GetCSharpDataType()该PDM字段类型未设置对应的C#类型{0}", pdmDataType)); } }
/// <summary> /// 是否可以以T?的形式构建可空类型 /// </summary> /// <param name="dataType"></param> /// <returns></returns> public static bool IsNullableType(this PDMDataType dataType) { switch (dataType) { case PDMDataType.varchar: case PDMDataType.nvarchar: case PDMDataType.text: return(false); case PDMDataType.numeric: case PDMDataType.datetime: case PDMDataType.uniqueidentifier: case PDMDataType.boolean: return(true); default: throw new NotImplementedException(string.Format("IsNullableType()未实现该类型的空类型检测{0}", dataType)); } }
public static string GetCSharpDataTypeConvertString(this Column column) { PDMDataType pdmDataType = column.GetPDMDataType(); int length = column.Length; int precision = column.Precision; string value = "reader[nameof(this." + column.Name + ")]"; switch (pdmDataType) { case PDMDataType.varchar: case PDMDataType.nvarchar: case PDMDataType.text: case PDMDataType.numeric: case PDMDataType.datetime: case PDMDataType.boolean: return(string.Format("Convert.To{0}({1})", column.GetCSharpDataType(), value)); case PDMDataType.uniqueidentifier: return(string.Format("new Guid({0}.ToString())", value)); default: throw new NotImplementedException(string.Format("GetCSharpValue()该PDM字段类型未设置对应的C#类型{0}", pdmDataType)); } }