| | |
| | | if (propertyInfo != null) |
| | | { |
| | | sugarColumn = propertyInfo.GetCustomAttribute<SugarColumn>(); |
| | | dbType = propertyInfo != null ? propertyInfo.GetProperWithDbType() : SqlDbTypeName.NVarChar; |
| | | dbType = propertyInfo.PropertyType != null ? propertyInfo.GetProperWithDbType() : SqlDbTypeName.NVarChar; |
| | | } |
| | | dbType = dbType.ToLower(); |
| | | string val = value?.ToString(); |
| | |
| | | } |
| | | else |
| | | { |
| | | |
| | | int length = sugarColumn.Length; |
| | | if (length == 0) { return (true, null, null); } |
| | | if (length == 0) { return (true, null, value); } |
| | | //判断双字节与单字段 |
| | | else if (length < 8000 && |
| | | ((dbType.Substring(0, 1) != "n" |
| | |
| | | } |
| | | |
| | | private static readonly Dictionary<Type, string> ProperWithDbType = new Dictionary<Type, string>() { |
| | | { typeof(string),SqlDbTypeName.NVarChar }, |
| | | { typeof(DateTime),SqlDbTypeName.DateTime}, |
| | | {typeof(long),SqlDbTypeName.BigInt }, |
| | | {typeof(int),SqlDbTypeName.Int}, |
| | | { typeof(decimal),SqlDbTypeName.Decimal }, |
| | | { typeof(float),SqlDbTypeName.Float }, |
| | | { typeof(double),SqlDbTypeName.Double }, |
| | | { typeof(byte),SqlDbTypeName.Int },//类型待完 |
| | | { typeof(Guid),SqlDbTypeName.UniqueIdentifier} |
| | | { typeof(string), SqlDbTypeName.NVarChar }, |
| | | { typeof(DateTime), SqlDbTypeName.DateTime}, |
| | | { typeof(long), SqlDbTypeName.BigInt }, |
| | | { typeof(int), SqlDbTypeName.Int}, |
| | | { typeof(decimal), SqlDbTypeName.Decimal }, |
| | | { typeof(float), SqlDbTypeName.Float }, |
| | | { typeof(double), SqlDbTypeName.Double }, |
| | | { typeof(byte), SqlDbTypeName.Int },//类型待完 |
| | | { typeof(Guid), SqlDbTypeName.UniqueIdentifier} |
| | | }; |
| | | |
| | | public static string GetProperWithDbType(this PropertyInfo propertyInfo) |
| | | { |
| | | bool result = ProperWithDbType.TryGetValue(propertyInfo.PropertyType, out string value); |