From 15ea065e0c5d83dc12e8a7dff7878434a2f47a08 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Thu, 28 Sep 2017 11:28:28 +0800 Subject: [PATCH] - --- .../QueryableProvider/QueryableProvider.cs | 108 ++++++++++++++++++ Src/Asp.Net/SqlSugar/Interface/IQueryable.cs | 12 ++ 2 files changed, 120 insertions(+) diff --git a/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs b/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs index f7dd235a3..e027d522e 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs @@ -592,6 +592,15 @@ namespace SqlSugar this.CacheTime = cacheDurationInSeconds; return this; } + public ISugarQueryable WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue) + { + if (IsCache) + { + this.IsCache = true; + this.CacheTime = cacheDurationInSeconds; + } + return this; + } #region Async methods public Task SingleAsync() { @@ -1311,6 +1320,15 @@ namespace SqlSugar this.CacheTime = cacheDurationInSeconds; return this; } + public new ISugarQueryable WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue) + { + if (IsCache) + { + this.IsCache = true; + this.CacheTime = cacheDurationInSeconds; + } + return this; + } #endregion } #endregion @@ -1526,6 +1544,15 @@ namespace SqlSugar this.CacheTime = cacheDurationInSeconds; return this; } + public new ISugarQueryable WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue) + { + if (IsCache) + { + this.IsCache = true; + this.CacheTime = cacheDurationInSeconds; + } + return this; + } #endregion } #endregion @@ -1762,6 +1789,15 @@ namespace SqlSugar this.CacheTime = cacheDurationInSeconds; return this; } + public new ISugarQueryable WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue) + { + if (IsCache) + { + this.IsCache = true; + this.CacheTime = cacheDurationInSeconds; + } + return this; + } #endregion } #endregion @@ -2024,6 +2060,15 @@ namespace SqlSugar this.CacheTime = cacheDurationInSeconds; return this; } + public new ISugarQueryable WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue) + { + if (IsCache) + { + this.IsCache = true; + this.CacheTime = cacheDurationInSeconds; + } + return this; + } #endregion } #endregion @@ -2312,6 +2357,15 @@ namespace SqlSugar this.CacheTime = cacheDurationInSeconds; return this; } + public new ISugarQueryable WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue) + { + if (IsCache) + { + this.IsCache = true; + this.CacheTime = cacheDurationInSeconds; + } + return this; + } #endregion } #endregion @@ -2627,6 +2681,15 @@ namespace SqlSugar this.CacheTime = cacheDurationInSeconds; return this; } + public new ISugarQueryable WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue) + { + if (IsCache) + { + this.IsCache = true; + this.CacheTime = cacheDurationInSeconds; + } + return this; + } #endregion } #endregion @@ -2968,6 +3031,15 @@ namespace SqlSugar this.CacheTime = cacheDurationInSeconds; return this; } + public new ISugarQueryable WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue) + { + if (IsCache) + { + this.IsCache = true; + this.CacheTime = cacheDurationInSeconds; + } + return this; + } #endregion } #endregion @@ -3332,6 +3404,15 @@ namespace SqlSugar this.CacheTime = cacheDurationInSeconds; return this; } + public new ISugarQueryable WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue) + { + if (IsCache) + { + this.IsCache = true; + this.CacheTime = cacheDurationInSeconds; + } + return this; + } #endregion } #endregion @@ -3720,6 +3801,15 @@ namespace SqlSugar this.CacheTime = cacheDurationInSeconds; return this; } + public new ISugarQueryable WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue) + { + if (IsCache) + { + this.IsCache = true; + this.CacheTime = cacheDurationInSeconds; + } + return this; + } #endregion } #endregion @@ -4133,6 +4223,15 @@ namespace SqlSugar this.CacheTime = cacheDurationInSeconds; return this; } + public new ISugarQueryable WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue) + { + if (IsCache) + { + this.IsCache = true; + this.CacheTime = cacheDurationInSeconds; + } + return this; + } #endregion } #endregion @@ -4570,6 +4669,15 @@ namespace SqlSugar this.CacheTime = cacheDurationInSeconds; return this; } + public new ISugarQueryable WithCacheIF(bool isCache,int cacheDurationInSeconds = int.MaxValue) + { + if (IsCache) + { + this.IsCache = true; + this.CacheTime = cacheDurationInSeconds; + } + return this; + } #endregion } #endregion diff --git a/Src/Asp.Net/SqlSugar/Interface/IQueryable.cs b/Src/Asp.Net/SqlSugar/Interface/IQueryable.cs index a945cd18b..16e8797f0 100644 --- a/Src/Asp.Net/SqlSugar/Interface/IQueryable.cs +++ b/Src/Asp.Net/SqlSugar/Interface/IQueryable.cs @@ -122,6 +122,7 @@ namespace SqlSugar List ToPageList(int pageIndex, int pageSize, ref int totalNumber); Task,int>> ToPageListAsync(int pageIndex, int pageSize, int totalNumber); ISugarQueryable WithCache(int cacheDurationInSeconds = int.MaxValue); + ISugarQueryable WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue); void Clear(); } public partial interface ISugarQueryable : ISugarQueryable @@ -178,6 +179,7 @@ namespace SqlSugar new ISugarQueryable AddJoinInfo(string tableName, string shortName, string joinWhere, JoinType type = JoinType.Left); new ISugarQueryable With(string withString); new ISugarQueryable WithCache(int cacheDurationInSeconds = int.MaxValue); + new ISugarQueryable WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue); #endregion } public partial interface ISugarQueryable : ISugarQueryable @@ -235,6 +237,7 @@ namespace SqlSugar new ISugarQueryable AddJoinInfo(string tableName, string shortName, string joinWhere, JoinType type = JoinType.Left); new ISugarQueryable With(string withString); new ISugarQueryable WithCache(int cacheDurationInSeconds = int.MaxValue); + new ISugarQueryable WithCacheIF(bool isCache,int cacheDurationInSeconds = int.MaxValue); #endregion } public partial interface ISugarQueryable : ISugarQueryable @@ -297,6 +300,7 @@ namespace SqlSugar new ISugarQueryable AddJoinInfo(string tableName, string shortName, string joinWhere, JoinType type = JoinType.Left); new ISugarQueryable With(string withString); new ISugarQueryable WithCache(int cacheDurationInSeconds = int.MaxValue); + new ISugarQueryable WithCacheIF(bool isCache,int cacheDurationInSeconds = int.MaxValue); #endregion } public partial interface ISugarQueryable : ISugarQueryable @@ -365,6 +369,7 @@ namespace SqlSugar new ISugarQueryable AddJoinInfo(string tableName, string shortName, string joinWhere, JoinType type = JoinType.Left); new ISugarQueryable With(string withString); new ISugarQueryable WithCache(int cacheDurationInSeconds = int.MaxValue); + new ISugarQueryable WithCacheIF(bool isCache,int cacheDurationInSeconds = int.MaxValue); #endregion } public partial interface ISugarQueryable : ISugarQueryable @@ -437,6 +442,7 @@ namespace SqlSugar new ISugarQueryable AddJoinInfo(string tableName, string shortName, string joinWhere, JoinType type = JoinType.Left); new ISugarQueryable With(string withString); new ISugarQueryable WithCache(int cacheDurationInSeconds = int.MaxValue); + new ISugarQueryable WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue); #endregion } public partial interface ISugarQueryable : ISugarQueryable @@ -514,6 +520,7 @@ namespace SqlSugar new ISugarQueryable AddJoinInfo(string tableName, string shortName, string joinWhere, JoinType type = JoinType.Left); new ISugarQueryable With(string withString); new ISugarQueryable WithCache(int cacheDurationInSeconds = int.MaxValue); + new ISugarQueryable WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue); #endregion } public partial interface ISugarQueryable : ISugarQueryable @@ -596,6 +603,7 @@ namespace SqlSugar new ISugarQueryable AddJoinInfo(string tableName, string shortName, string joinWhere, JoinType type = JoinType.Left); new ISugarQueryable With(string withString); new ISugarQueryable WithCache(int cacheDurationInSeconds = int.MaxValue); + new ISugarQueryable WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue); #endregion } @@ -685,6 +693,7 @@ namespace SqlSugar new ISugarQueryable AddJoinInfo(string tableName, string shortName, string joinWhere, JoinType type = JoinType.Left); new ISugarQueryable With(string withString); new ISugarQueryable WithCache(int cacheDurationInSeconds = int.MaxValue); + new ISugarQueryable WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue); #endregion } public partial interface ISugarQueryable : ISugarQueryable @@ -777,6 +786,7 @@ namespace SqlSugar new ISugarQueryable AddJoinInfo(string tableName, string shortName, string joinWhere, JoinType type = JoinType.Left); new ISugarQueryable With(string withString); new ISugarQueryable WithCache(int cacheDurationInSeconds = int.MaxValue); + new ISugarQueryable WithCacheIF(bool isCache,int cacheDurationInSeconds = int.MaxValue); #endregion } public partial interface ISugarQueryable : ISugarQueryable @@ -874,6 +884,7 @@ namespace SqlSugar new ISugarQueryable AddJoinInfo(string tableName, string shortName, string joinWhere, JoinType type = JoinType.Left); new ISugarQueryable With(string withString); new ISugarQueryable WithCache(int cacheDurationInSeconds = int.MaxValue); + new ISugarQueryable WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue); #endregion } public partial interface ISugarQueryable : ISugarQueryable @@ -976,6 +987,7 @@ namespace SqlSugar new ISugarQueryable AddJoinInfo(string tableName, string shortName, string joinWhere, JoinType type = JoinType.Left); new ISugarQueryable With(string withString); new ISugarQueryable WithCache(int cacheDurationInSeconds = int.MaxValue); + new ISugarQueryable WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue); #endregion } #endregion