From 8f872af917daaf693368b166a6985410976ca30a Mon Sep 17 00:00:00 2001 From: huangxiaoqiang <1247017146@qq.com> Date: 星期一, 07 四月 2025 14:23:43 +0800 Subject: [PATCH] 优化底层查询添加 --- Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Core/Utilities/EntityProperties.cs | 64 +++++++++++++++++++++++++++++--- 1 files changed, 58 insertions(+), 6 deletions(-) diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Core/Utilities/EntityProperties.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Core/Utilities/EntityProperties.cs index 11ea985..b22b218 100644 --- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Core/Utilities/EntityProperties.cs +++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Core/Utilities/EntityProperties.cs @@ -147,6 +147,58 @@ /// <param name="removeNotContains">绉婚櫎涓嶅瓨鍦ㄥ瓧娈�</param> /// <param name="removerKey">绉婚櫎涓婚敭</param> /// <returns></returns> + //public static string ValidateDicInEntity(this Type typeinfo, Dictionary<string, object> dic, bool removerKey, PropertyInfo[] propertyInfo, string[] ignoreFields = null) + //{ + // if (dic == null || dic.Count == 0) { return "鍙傛暟鏃犳晥"; } + + // // 涓嶅瓨鍦ㄧ殑瀛楁鐩存帴绉婚櫎 + // dic.Where(x => !propertyInfo.Any(p => p.Name.ToUpper() == x.Key.ToUpper())).Select(s => s.Key).ToList().ForEach(f => + // { + // dic.Remove(f); + // }); + + // string keyName = typeinfo.GetKeyName(); + // //绉婚櫎涓婚敭 + // if (removerKey) + // dic.Remove(keyName); + // //else + // //{ + // // if (!dic.ContainsKey(keyName)) + // // return "璇蜂紶鍏ヤ富閿弬鏁�"; + // //} + + // foreach (PropertyInfo property in propertyInfo) + // { + // SugarColumn sugarColumn = property.GetCustomAttribute<SugarColumn>(); + // if (sugarColumn == null) + // return "璇烽厤缃甋ugarColumn灞炴��"; + // //蹇界暐涓庝富閿殑瀛楁涓嶅仛楠岃瘉 + // if (property.Name.ToUpper() == keyName.ToUpper() || (ignoreFields != null && ignoreFields.Contains(property.Name)) || sugarColumn.IsOnlyIgnoreInsert || sugarColumn.IsOnlyIgnoreUpdate || sugarColumn.IsIgnore) + // continue; + + // //涓嶅湪缂栬緫涓殑鍒楋紝鏄惁涔熻蹇呭~ + // if (!dic.ContainsKey(property.Name.ToUpper())) + // { + // if (!sugarColumn.IsNullable) + // { + // if (sugarColumn.DefaultValue == null) + // return sugarColumn.ColumnDescription + "涓哄繀椤绘彁浜ら」"; + // continue; + // } + // continue; + // } + // if(dic[property.Name.ToUpper()] != null) + // { + // string str = dic[property.Name.ToUpper()].ToString(); + // //灏嗘墍鏈夌┖鍊艰缃负null + // if (str == string.Empty) + // dic[property.Name.ToUpper()] = null; + // } + + // } + // return string.Empty; + //} + public static string ValidateDicInEntity(this Type typeinfo, Dictionary<string, object> dic, bool removerKey, PropertyInfo[] propertyInfo, string[] ignoreFields = null) { if (dic == null || dic.Count == 0) { return "鍙傛暟鏃犳晥"; } @@ -173,11 +225,11 @@ if (sugarColumn == null) return "璇烽厤缃甋ugarColumn灞炴��"; //蹇界暐涓庝富閿殑瀛楁涓嶅仛楠岃瘉 - if (property.Name.ToUpper() == keyName.ToUpper() || (ignoreFields != null && ignoreFields.Contains(property.Name)) || sugarColumn.IsOnlyIgnoreInsert || sugarColumn.IsOnlyIgnoreUpdate || sugarColumn.IsIgnore) + if (property.Name == keyName.FirstLetterToUpper() || (ignoreFields != null && ignoreFields.Contains(property.Name)) || sugarColumn.IsOnlyIgnoreInsert || sugarColumn.IsOnlyIgnoreUpdate || sugarColumn.IsIgnore) continue; //涓嶅湪缂栬緫涓殑鍒楋紝鏄惁涔熻蹇呭~ - if (!dic.ContainsKey(property.Name.ToUpper())) + if (!dic.ContainsKey(property.Name.FirstLetterToLower())) { if (!sugarColumn.IsNullable) { @@ -187,14 +239,14 @@ } continue; } - if(dic[property.Name.ToUpper()] != null) + if (dic[property.Name.FirstLetterToLower()] != null) { - string str = dic[property.Name.ToUpper()].ToString(); + string str = dic[property.Name.FirstLetterToLower()].ToString(); //灏嗘墍鏈夌┖鍊艰缃负null if (str == string.Empty) - dic[property.Name.ToUpper()] = null; + dic[property.Name.FirstLetterToLower()] = null; } - + } return string.Empty; } -- Gitblit v1.9.3