|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else if (dbType == SqlDbTypeName.Float || dbType == SqlDbTypeName.Decimal || dbType == SqlDbTypeName.Double) | 
|---|
|  |  |  | { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (!val.IsNumber(null)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | reslutMsg = "不是有效数字"; | 
|---|
|  |  |  | 
|---|
|  |  |  | || dbType == SqlDbTypeName.Char | 
|---|
|  |  |  | || dbType == SqlDbTypeName.Text)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //默认nvarchar(max) 、text 长度不能超过20000 | 
|---|
|  |  |  | if (val.Length > 200000) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | int length = sugarColumn.Length; | 
|---|
|  |  |  | if (length == 0) { return (true, null, null); } | 
|---|
|  |  |  | //判断双字节与单字段 | 
|---|
|  |  |  | 
|---|
|  |  |  | {  typeof(byte),SqlDbTypeName.Int },//类型待完 | 
|---|
|  |  |  | { typeof(Guid),SqlDbTypeName.UniqueIdentifier} | 
|---|
|  |  |  | }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static string GetProperWithDbType(this PropertyInfo propertyInfo) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | bool result = ProperWithDbType.TryGetValue(propertyInfo.PropertyType, out string value); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | string str = dic[property.Name.FirstLetterToLower()].ToString(); | 
|---|
|  |  |  | string str = dic.GetValueOrDefault(property.Name.FirstLetterToLower(), "").ToString(); | 
|---|
|  |  |  | //将所有空值设置为null | 
|---|
|  |  |  | if (dic[property.Name.FirstLetterToLower()] != null && str == string.Empty) | 
|---|
|  |  |  | dic[property.Name.FirstLetterToLower()] = null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return string.Empty; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// 安全获取字典值,如果键不存在或值为null则返回默认值 | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | /// <typeparam name="TKey">字典键的类型</typeparam> | 
|---|
|  |  |  | /// <typeparam name="TValue">字典值的类型</typeparam> | 
|---|
|  |  |  | /// <param name="dictionary">字典实例</param> | 
|---|
|  |  |  | /// <param name="key">键</param> | 
|---|
|  |  |  | /// <param name="defaultValue">默认值</param> | 
|---|
|  |  |  | /// <returns>字典值或默认值</returns> | 
|---|
|  |  |  | public static TValue GetValueOrDefault<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key, TValue defaultValue = default) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (dictionary == null) throw new ArgumentNullException(nameof(dictionary)); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return dictionary.TryGetValue(key, out TValue value) && value != null ? value : defaultValue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static string GetKeyName(this Type typeinfo) | 
|---|
|  |  |  | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|