From 28f1259ec675a191d2a852f74566400e6cc40b50 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期三, 11 九月 2024 17:03:11 +0800
Subject: [PATCH] 前端问题改动,与代码优化

---
 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Core/Utilities/EntityProperties.cs |   24 +++++++++++++++++++-----
 1 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Core/Utilities/EntityProperties.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Core/Utilities/EntityProperties.cs
index ab77042..367eda1 100644
--- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Core/Utilities/EntityProperties.cs
+++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Core/Utilities/EntityProperties.cs
@@ -58,7 +58,6 @@
             }
             else if (dbType == SqlDbTypeName.Float || dbType == SqlDbTypeName.Decimal || dbType == SqlDbTypeName.Double)
             {
-
                 if (!val.IsNumber(null))
                 {
                     reslutMsg = "涓嶆槸鏈夋晥鏁板瓧";
@@ -78,7 +77,6 @@
                 || dbType == SqlDbTypeName.Char
                 || dbType == SqlDbTypeName.Text))
             {
-
                 //榛樿nvarchar(max) 銆乼ext 闀垮害涓嶈兘瓒呰繃20000
                 if (val.Length > 200000)
                 {
@@ -86,7 +84,6 @@
                 }
                 else
                 {
-
                     int length = sugarColumn.Length;
                     if (length == 0) { return (true, null, null); }
                     //鍒ゆ柇鍙屽瓧鑺備笌鍗曞瓧娈�
@@ -118,6 +115,7 @@
             {  typeof(byte),SqlDbTypeName.Int },//绫诲瀷寰呭畬
             { typeof(Guid),SqlDbTypeName.UniqueIdentifier}
         };
+
         public static string GetProperWithDbType(this PropertyInfo propertyInfo)
         {
             bool result = ProperWithDbType.TryGetValue(propertyInfo.PropertyType, out string value);
@@ -189,12 +187,28 @@
                     }
                     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)
@@ -294,4 +308,4 @@
             return null;
         }
     }
-}
+}
\ No newline at end of file

--
Gitblit v1.9.3