diff --git a/Src/Asp.Net/SqlSugar/Infrastructure/ContextMethods.cs b/Src/Asp.Net/SqlSugar/Infrastructure/ContextMethods.cs index fe7da6fb8..51beea0a7 100644 --- a/Src/Asp.Net/SqlSugar/Infrastructure/ContextMethods.cs +++ b/Src/Asp.Net/SqlSugar/Infrastructure/ContextMethods.cs @@ -323,6 +323,11 @@ namespace SqlSugar } return this.DeserializeObject>(this.SerializeObject(deserializeObject)); } + public Dictionary DataTableToDictionary(DataTable table) + { + return table.Rows.Cast().ToDictionary(x => x[0].ToString(), x => x[1]); + } + #endregion #region Cache diff --git a/Src/Asp.Net/SqlSugar/Interface/IContextMethods.cs b/Src/Asp.Net/SqlSugar/Interface/IContextMethods.cs index 898e350d3..2d04a62c5 100644 --- a/Src/Asp.Net/SqlSugar/Interface/IContextMethods.cs +++ b/Src/Asp.Net/SqlSugar/Interface/IContextMethods.cs @@ -20,6 +20,7 @@ namespace SqlSugar SqlSugarEngine CopyContext(bool isCopyEvents = false); dynamic DataTableToDynamic(DataTable table); List DataTableToList(DataTable table); + Dictionary DataTableToDictionary(DataTable table); ICacheService GetReflectionInoCacheInstance(); void RemoveCacheAll(); void RemoveCacheAll();