From a91e720faba58378bdf1d3da8115e64efaff5a1a Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Thu, 25 Apr 2024 12:13:11 +0800 Subject: [PATCH] Synchronization code --- .../Abstract/QueryableProvider/QueryableExecuteSql.cs | 5 ++++- .../Abstract/QueryableProvider/QueryableExecuteSqlAsync.cs | 5 ++++- Src/Asp.Net/SqlSugar/Interface/IQueryable.cs | 2 ++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableExecuteSql.cs b/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableExecuteSql.cs index 41ffde539..232a1512c 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableExecuteSql.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableExecuteSql.cs @@ -468,7 +468,10 @@ namespace SqlSugar totalPage = (totalNumber + pageSize - 1) / pageSize; return result; } - + public Dictionary ToDictionary(Expression> key, Expression> value) + { + return this.ToDictionary(key, value).ToDictionary(it => it.Key, it => (ValueType)UtilMethods.ChangeType2(it.Value, typeof(ValueType))); + } public Dictionary ToDictionary(Expression> key, Expression> value) { if (this.QueryBuilder.IsSingle() == false && (this.QueryBuilder.AsTables == null||this.QueryBuilder.AsTables.Count==0)) diff --git a/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableExecuteSqlAsync.cs b/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableExecuteSqlAsync.cs index c217529eb..2127ba8cd 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableExecuteSqlAsync.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableExecuteSqlAsync.cs @@ -573,7 +573,10 @@ ParameterT parameter) result = result.Where(it => it.GetType().GetProperty(name).GetValue(it).ObjToString() == pkValue.ObjToString()).ToList(); return result; } - + public async Task> ToDictionaryAsync(Expression> key, Expression> value) + { + return (await this.ToDictionaryAsync(key, value)).ToDictionary(it => it.Key, it => (ValueType)UtilMethods.ChangeType2(it.Value, typeof(ValueType))); + } public async Task> ToDictionaryAsync(Expression> key, Expression> value) { if (this.QueryBuilder.IsSingle() == false && (this.QueryBuilder.AsTables == null || this.QueryBuilder.AsTables.Count == 0)) diff --git a/Src/Asp.Net/SqlSugar/Interface/IQueryable.cs b/Src/Asp.Net/SqlSugar/Interface/IQueryable.cs index ecce5e045..bcbab6111 100644 --- a/Src/Asp.Net/SqlSugar/Interface/IQueryable.cs +++ b/Src/Asp.Net/SqlSugar/Interface/IQueryable.cs @@ -216,8 +216,10 @@ namespace SqlSugar List SetContext(Expression> thisFiled1, Expression> mappingFiled1, Expression> thisFiled2, Expression> mappingFiled2, ParameterT parameter); Task > SetContextAsync(Expression> thisFiled, Expression> mappingFiled, ParameterT parameter); Task> SetContextAsync(Expression> thisFiled1, Expression> mappingFiled1, Expression> thisFiled2, Expression> mappingFiled2, ParameterT parameter); + Dictionary ToDictionary(Expression> key, Expression> value); Dictionary ToDictionary(Expression> key, Expression> value); Task> ToDictionaryAsync(Expression> key, Expression> value); + Task> ToDictionaryAsync(Expression> key, Expression> value); List> ToDictionaryList(); Task>> ToDictionaryListAsync();