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();