From fecffff14ca95e229a1ec7d309a44195427420eb Mon Sep 17 00:00:00 2001 From: SUNKAIXUAN <610262374@qq.com> Date: Sat, 27 Mar 2021 13:17:40 +0800 Subject: [PATCH] Update Cache --- .../SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs | 2 ++ .../SqlSugar/Abstract/SqlBuilderProvider/QueryBuilder.cs | 1 + Src/Asp.Net/SqlSugar/CacheScheme/CacheKeyBuider.cs | 5 +++++ Src/Asp.Net/SqlSugar/CacheScheme/CacheSchemeMain.cs | 2 +- 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs b/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs index 231afc074..12e19f118 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs @@ -954,6 +954,7 @@ namespace SqlSugar public virtual DataTable ToDataTable() { + QueryBuilder.ResultType = typeof(DataTable); InitMapping(); var sqlObj = this.ToSql(); RestoreMapping(); @@ -1324,6 +1325,7 @@ namespace SqlSugar } public async Task ToDataTableAsync() { + QueryBuilder.ResultType = typeof(DataTable); InitMapping(); var sqlObj = this.ToSql(); RestoreMapping(); diff --git a/Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/QueryBuilder.cs b/Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/QueryBuilder.cs index 9447c15ca..fb38272f1 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/QueryBuilder.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/QueryBuilder.cs @@ -48,6 +48,7 @@ namespace SqlSugar public Type EntityType { get; set; } + public Type ResultType { get; set; } public string TableWithString { get; set; } public string GroupByValue { get; set; } public string PartitionByValue { get; set; } diff --git a/Src/Asp.Net/SqlSugar/CacheScheme/CacheKeyBuider.cs b/Src/Asp.Net/SqlSugar/CacheScheme/CacheKeyBuider.cs index 856a06863..8eac7f894 100644 --- a/Src/Asp.Net/SqlSugar/CacheScheme/CacheKeyBuider.cs +++ b/Src/Asp.Net/SqlSugar/CacheScheme/CacheKeyBuider.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Data; using System.Linq; using System.Text; @@ -13,6 +14,10 @@ namespace SqlSugar result.Database = context.Context.Ado.Connection.Database; AddTables(context, queryBuilder, result); AddIdentificationList(queryBuilder, result); + if (queryBuilder.ResultType!=null) + { + result.IdentificationList.Add(queryBuilder.ResultType.FullName); + } return result; } diff --git a/Src/Asp.Net/SqlSugar/CacheScheme/CacheSchemeMain.cs b/Src/Asp.Net/SqlSugar/CacheScheme/CacheSchemeMain.cs index 1f8b0b23c..c487e330d 100644 --- a/Src/Asp.Net/SqlSugar/CacheScheme/CacheSchemeMain.cs +++ b/Src/Asp.Net/SqlSugar/CacheScheme/CacheSchemeMain.cs @@ -44,7 +44,7 @@ namespace SqlSugar { foreach (var item in keys) { - if (item.ToLower().Contains(likeString)) + if (item.ToLower().Contains(likeString.ToLower())) { cacheService.Remove(item); }