diff --git a/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs b/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs index 51d4e8384..c0c1ad93d 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs @@ -1006,17 +1006,23 @@ namespace SqlSugar { List result = null; var sqlObj = this.ToSql(); - var isComplexModel = QueryBuilder.IsComplexModel(sqlObj.Key); - var entityType = typeof(TResult); - result = GetData(sqlObj, isComplexModel, entityType); - RestoreMapping(); - SetContextModel(result, entityType); + if (IsCache) + { + var cacheService = this.Context.CurrentConnectionConfig.ConfigureExternalServices.DataInfoCache; + result = CacheSchemeMain.GetOrCreate>(cacheService, this.Context, this.QueryBuilder,()=> { return GetData(sqlObj); }); + } + else + { + result = GetData(sqlObj); + } return result; } - protected List GetData(KeyValuePair> sqlObj, bool isComplexModel, Type entityType) + protected List GetData(KeyValuePair> sqlObj) { List result; + var isComplexModel = QueryBuilder.IsComplexModel(sqlObj.Key); + var entityType = typeof(TResult); var dataReader = this.Db.GetDataReader(sqlObj.Key, sqlObj.Value.ToArray()); if (typeof(TResult) == typeof(ExpandoObject)) { @@ -1030,6 +1036,8 @@ namespace SqlSugar { result = this.Bind.DataReaderToList(entityType, dataReader, QueryBuilder.SelectCacheKey); } + RestoreMapping(); + SetContextModel(result, entityType); return result; } diff --git a/Src/Asp.Net/SqlSugar/CacheScheme/CacheEngines.cs b/Src/Asp.Net/SqlSugar/CacheScheme/CacheEngines.cs new file mode 100644 index 000000000..63fe98a45 --- /dev/null +++ b/Src/Asp.Net/SqlSugar/CacheScheme/CacheEngines.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace SqlSugar +{ + internal class CacheEngines + { + public string GetCacheMapping() + { + return null; + } + + public string GetCacheData() + { + return null; + } + } +} diff --git a/Src/Asp.Net/SqlSugar/CacheScheme/CacheKeyBuider.cs b/Src/Asp.Net/SqlSugar/CacheScheme/CacheKeyBuider.cs new file mode 100644 index 000000000..d9e72e4a6 --- /dev/null +++ b/Src/Asp.Net/SqlSugar/CacheScheme/CacheKeyBuider.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace SqlSugar +{ + internal class CacheKeyBuider + { + public static CacheKey GetKey(SqlSugarClient context, QueryBuilder queryBuilder) + { + throw new NotImplementedException(); + } + } +} diff --git a/Src/Asp.Net/SqlSugar/CacheScheme/CacheSchemeMain.cs b/Src/Asp.Net/SqlSugar/CacheScheme/CacheSchemeMain.cs new file mode 100644 index 000000000..fcd8121fd --- /dev/null +++ b/Src/Asp.Net/SqlSugar/CacheScheme/CacheSchemeMain.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace SqlSugar +{ + internal class CacheSchemeMain + { + + public static T GetOrCreate(ICacheService cacheService, SqlSugarClient context, QueryBuilder queryBuilder,Func getData) + { + string key = CacheKeyBuider.GetKey(context,queryBuilder).ToString(); + var result= cacheService.GetOrCreate(key, () => getData()); + return result; + } + } +} diff --git a/Src/Asp.Net/SqlSugar/Entities/CacheKey.cs b/Src/Asp.Net/SqlSugar/Entities/CacheKey.cs new file mode 100644 index 000000000..eff2704dd --- /dev/null +++ b/Src/Asp.Net/SqlSugar/Entities/CacheKey.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace SqlSugar +{ + public class CacheKey + { + public new string ToString() { + return ""; + } + } +} diff --git a/Src/Asp.Net/SqlSugar/SqlSugar.csproj b/Src/Asp.Net/SqlSugar/SqlSugar.csproj index 6a1cd177f..03b4405ec 100644 --- a/Src/Asp.Net/SqlSugar/SqlSugar.csproj +++ b/Src/Asp.Net/SqlSugar/SqlSugar.csproj @@ -72,6 +72,10 @@ + + + + @@ -252,6 +256,7 @@ +