From f2e75050029583863b28da8e358be112981c41e2 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Sun, 15 Jan 2023 20:00:45 +0800 Subject: [PATCH] Synchronization code --- .../SqlSugar/Infrastructure/ContextMethods.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Src/Asp.NetCore2/SqlSugar/Infrastructure/ContextMethods.cs b/Src/Asp.NetCore2/SqlSugar/Infrastructure/ContextMethods.cs index 14d790b8c..d997d8dd1 100644 --- a/Src/Asp.NetCore2/SqlSugar/Infrastructure/ContextMethods.cs +++ b/Src/Asp.NetCore2/SqlSugar/Infrastructure/ContextMethods.cs @@ -386,7 +386,11 @@ namespace SqlSugar } else if (IsJsonItem(readerValues, name)) { - result.Add(name, DeserializeObject>(readerValues.First(it=>it.Key.EqualCase(name)).Value.ObjToString())); + result.Add(name, DeserializeObject>(readerValues.First(it => it.Key.EqualCase(name)).Value.ObjToString())); + } + else if (IsArrayItem(readerValues, item)) + { + result.Add(name, DeserializeObject(readerValues.First(y => y.Key.EqualCase(item.Name)).Value + "")); } else if (IsJsonList(readerValues, item)) { @@ -397,7 +401,7 @@ namespace SqlSugar { result.Add(name, (byte[])readerValues[item.Name.ToLower()]); } - else if (item.PropertyType == typeof(object)) + else if (item.PropertyType == typeof(object)) { result.Add(name, readerValues[item.Name.ToLower()]); } @@ -453,6 +457,7 @@ namespace SqlSugar return result; } + private void SetAppendColumns(IDataReader dataReader) { if (QueryBuilder != null && QueryBuilder.AppendColumns != null && QueryBuilder.AppendColumns.Any()) @@ -498,6 +503,12 @@ namespace SqlSugar Regex.IsMatch(readerValues.First().Value.ObjToString(), @"^\{.+\}$"); } + + private static bool IsArrayItem(Dictionary readerValues, PropertyInfo item) + { + return item.PropertyType.IsArray && readerValues.Any(y => y.Key.EqualCase(item.Name)) && readerValues.FirstOrDefault(y => y.Key.EqualCase(item.Name)).Value is string; + } + private static bool IsJsonList(Dictionary readerValues, PropertyInfo item) { return item.PropertyType.FullName.IsCollectionsList() &&