/// <summary> /// 获取名称 /// </summary> private string N(PropertyModel col) { return col.Name.TrimStart('@'); }
/// <summary> /// 获取System.Type /// </summary> /// <returns>System.Type</returns> private string ST(PropertyModel col) { string sqlType = col.Type.Split('(')[0].ToLower(); switch (sqlType) { case "system.boolean": case "bit": case "bool": { if (IsJava) return "boolean"; else return "bool";//bool } case "system.byte": case "tinyint": { if (col.Type.ToLower() == "tinyint(1)") { if (IsJava) return "boolean"; else return "bool";//bool } else return "byte";//byte } case "system.int16": case "smallint": return "short";//short case "system.int32": case "int": case "integer": return "int";//int case "system.int64": case "bigint": return "long";//long case "system.single": case "real": case "float": case "single": return "float";//float case "system.double": case "double": return "double"; //double case "system.decimal": case "money": case "smallmoney": case "numeric": case "decimal": return "decimal";//decimal case "system.string": case "char": case "nchar": case "varchar": case "nvarchar": case "text": case "ntext": case "xml": { if (IsJava) return "String"; else return "string";//string } case "image": case "binary": case "varbinary": case "bolb": return "byte[]"; case "system.dateTime": case "datetime": case "datetime2": case "date": case "smalldatetime": { if (IsJava) return "Date"; else return "DateTime";//DateTime } case "time": { if (IsJava) return "Time"; else return "DateTime";//DateTime } default: { if (IsJava) return "String"; else return "string";//string } } }
/// <summary> /// 获取System.Data.DbType /// </summary> /// <param name="col"></param> /// <returns>System.Data.DbType</returns> private string DT(PropertyModel col) { string sqlType = col.Type.Split('(')[0].ToLower(); switch (sqlType) { case "system.boolean": case "bit": case "bool": return "DbType.Boolean";//bool case "system.byte": case "tinyint": { if (col.Type.ToLower() == "tinyint(1)") return "DbType.Boolean"; else return "DbType.Byte";//byte } case "system.int16": case "smallint": return "DbType.Int16";//short case "system.int32": case "int": case "integer": return "DbType.Int32";//int case "system.int64": case "bigint": return "DbType.Int64";//long case "system.single": case "single": case "real": return "DbType.Single";//float case "dystem.double": case "float"://在sqlserver 里 real相当于float; float 相当于 double; case "double": return "DbType.Double"; case "system.decimal": case "money": case "smallmoney": case "numeric": case "decimal": return "DbType.Decimal";//decimal case "system.string": case "char": case "nchar": case "varchar": case "nvarchar": case "text": case "ntext": case "xml": return "DbType.String";//string case "image": case "binary": case "varbinary": case "bolb": return "DbType.Binary";//Binary case "system.dateTime": case "datetime": case "datetime2": case "date": case "time": case "smalldatetime": return "DbType.DateTime";//DateTime default: return "DbType.String"; } }