mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2026-02-04 23:09:48 +08:00
【优化】仓储底层增加常用统计数据的缓存处理。
This commit is contained in:
@@ -43,7 +43,7 @@ namespace CoreCms.Net.Repository
|
||||
/// <param name="pkValue">主键值</param>
|
||||
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
|
||||
/// <param name="isDataCache">是否启用缓存</param>
|
||||
/// <param name="cacheTimes">缓存时长(秒)</param>
|
||||
/// <param name="cacheTimes">缓存时长(分钟)</param>
|
||||
/// <returns>泛型实体</returns>
|
||||
public T QueryById(object pkValue, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
|
||||
{
|
||||
@@ -58,7 +58,7 @@ namespace CoreCms.Net.Repository
|
||||
/// <param name="objId">id(必须指定主键特性 [SugarColumn(IsPrimaryKey=true)]),如果是联合主键,请使用Where条件</param>
|
||||
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
|
||||
/// <param name="isDataCache">是否启用缓存</param>
|
||||
/// <param name="cacheTimes">缓存时长(秒)</param>
|
||||
/// <param name="cacheTimes">缓存时长(分钟)</param>
|
||||
/// <returns>数据实体</returns>
|
||||
public async Task<T> QueryByIdAsync(object objId, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
|
||||
{
|
||||
@@ -74,7 +74,7 @@ namespace CoreCms.Net.Repository
|
||||
/// <returns>数据实体列表</returns>
|
||||
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
|
||||
/// <param name="isDataCache">是否启用缓存</param>
|
||||
/// <param name="cacheTimes">缓存时长(秒)</param>
|
||||
/// <param name="cacheTimes">缓存时长(分钟)</param>
|
||||
public List<T> QueryByIDs(object[] lstIds, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
|
||||
{
|
||||
return blUseNoLock
|
||||
@@ -89,7 +89,7 @@ namespace CoreCms.Net.Repository
|
||||
/// <returns>数据实体列表</returns>
|
||||
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
|
||||
/// <param name="isDataCache">是否启用缓存</param>
|
||||
/// <param name="cacheTimes">缓存时长(秒)</param>
|
||||
/// <param name="cacheTimes">缓存时长(分钟)</param>
|
||||
public async Task<List<T>> QueryByIDsAsync(object[] lstIds, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
|
||||
{
|
||||
return blUseNoLock
|
||||
@@ -104,7 +104,7 @@ namespace CoreCms.Net.Repository
|
||||
/// <returns>数据实体列表</returns>
|
||||
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
|
||||
/// <param name="isDataCache">是否启用缓存</param>
|
||||
/// <param name="cacheTimes">缓存时长(秒)</param>
|
||||
/// <param name="cacheTimes">缓存时长(分钟)</param>
|
||||
public List<T> QueryByIDs(int[] lstIds, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
|
||||
{
|
||||
return blUseNoLock
|
||||
@@ -119,7 +119,7 @@ namespace CoreCms.Net.Repository
|
||||
/// <returns>数据实体列表</returns>
|
||||
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
|
||||
/// <param name="isDataCache">是否启用缓存</param>
|
||||
/// <param name="cacheTimes">缓存时长(秒)</param>
|
||||
/// <param name="cacheTimes">缓存时长(分钟)</param>
|
||||
public async Task<List<T>> QueryByIDsAsync(int[] lstIds, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
|
||||
{
|
||||
return blUseNoLock
|
||||
@@ -132,7 +132,7 @@ namespace CoreCms.Net.Repository
|
||||
/// </summary>
|
||||
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
|
||||
/// <param name="isDataCache">是否启用缓存</param>
|
||||
/// <param name="cacheTimes">缓存时长(秒)</param>
|
||||
/// <param name="cacheTimes">缓存时长(分钟)</param>
|
||||
/// <returns></returns>
|
||||
public List<T> Query(bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
|
||||
{
|
||||
@@ -146,7 +146,7 @@ namespace CoreCms.Net.Repository
|
||||
/// </summary>
|
||||
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
|
||||
/// <param name="isDataCache">是否启用缓存</param>
|
||||
/// <param name="cacheTimes">缓存时长(秒)</param>
|
||||
/// <param name="cacheTimes">缓存时长(分钟)</param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<T>> QueryAsync(bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
|
||||
{
|
||||
@@ -162,7 +162,7 @@ namespace CoreCms.Net.Repository
|
||||
/// <param name="orderBy">排序字段,如name asc,age desc</param>
|
||||
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
|
||||
/// <param name="isDataCache">是否启用缓存</param>
|
||||
/// <param name="cacheTimes">缓存时长(秒)</param>
|
||||
/// <param name="cacheTimes">缓存时长(分钟)</param>
|
||||
/// <returns>泛型实体集合</returns>
|
||||
public List<T> QueryListByClause(string strWhere, string orderBy = "", bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
|
||||
{
|
||||
@@ -188,7 +188,7 @@ namespace CoreCms.Net.Repository
|
||||
/// <returns>泛型实体集合</returns>
|
||||
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
|
||||
/// <param name="isDataCache">是否启用缓存</param>
|
||||
/// <param name="cacheTimes">缓存时长(秒)</param>
|
||||
/// <param name="cacheTimes">缓存时长(分钟)</param>
|
||||
public async Task<List<T>> QueryListByClauseAsync(string strWhere, string orderBy = "", bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
|
||||
{
|
||||
return blUseNoLock
|
||||
@@ -213,7 +213,7 @@ namespace CoreCms.Net.Repository
|
||||
/// <returns>泛型实体集合</returns>
|
||||
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
|
||||
/// <param name="isDataCache">是否启用缓存</param>
|
||||
/// <param name="cacheTimes">缓存时长(秒)</param>
|
||||
/// <param name="cacheTimes">缓存时长(分钟)</param>
|
||||
public List<T> QueryListByClause(Expression<Func<T, bool>> predicate, string orderBy = "", bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
|
||||
{
|
||||
return blUseNoLock
|
||||
@@ -238,7 +238,7 @@ namespace CoreCms.Net.Repository
|
||||
/// <returns>泛型实体集合</returns>
|
||||
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
|
||||
/// <param name="isDataCache">是否启用缓存</param>
|
||||
/// <param name="cacheTimes">缓存时长(秒)</param>
|
||||
/// <param name="cacheTimes">缓存时长(分钟)</param>
|
||||
public async Task<List<T>> QueryListByClauseAsync(Expression<Func<T, bool>> predicate, string orderBy = "", bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
|
||||
{
|
||||
return blUseNoLock
|
||||
@@ -263,7 +263,7 @@ namespace CoreCms.Net.Repository
|
||||
/// <param name="orderByType">排序顺序</param>
|
||||
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
|
||||
/// <param name="isDataCache">是否启用缓存</param>
|
||||
/// <param name="cacheTimes">缓存时长(秒)</param>
|
||||
/// <param name="cacheTimes">缓存时长(分钟)</param>
|
||||
/// <returns>泛型实体集合</returns>
|
||||
public List<T> QueryListByClause(Expression<Func<T, bool>> predicate, Expression<Func<T, object>> orderByPredicate, OrderByType orderByType, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
|
||||
{
|
||||
@@ -289,7 +289,7 @@ namespace CoreCms.Net.Repository
|
||||
/// <param name="orderByType">排序顺序</param>
|
||||
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
|
||||
/// <param name="isDataCache">是否启用缓存</param>
|
||||
/// <param name="cacheTimes">缓存时长(秒)</param>
|
||||
/// <param name="cacheTimes">缓存时长(分钟)</param>
|
||||
/// <returns>泛型实体集合</returns>
|
||||
public async Task<List<T>> QueryListByClauseAsync(Expression<Func<T, bool>> predicate, Expression<Func<T, object>> orderByPredicate, OrderByType orderByType, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
|
||||
{
|
||||
@@ -316,7 +316,7 @@ namespace CoreCms.Net.Repository
|
||||
/// <param name="orderByType">排序顺序</param>
|
||||
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
|
||||
/// <param name="isDataCache">是否启用缓存</param>
|
||||
/// <param name="cacheTimes">缓存时长(秒)</param>
|
||||
/// <param name="cacheTimes">缓存时长(分钟)</param>
|
||||
/// <returns></returns>
|
||||
public List<T> QueryListByClause(Expression<Func<T, bool>> predicate, int take, Expression<Func<T, object>> orderByPredicate, OrderByType orderByType, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
|
||||
{
|
||||
@@ -345,7 +345,7 @@ namespace CoreCms.Net.Repository
|
||||
/// <param name="orderByType">排序顺序</param>
|
||||
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
|
||||
/// <param name="isDataCache">是否启用缓存</param>
|
||||
/// <param name="cacheTimes">缓存时长(秒)</param>
|
||||
/// <param name="cacheTimes">缓存时长(分钟)</param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<T>> QueryListByClauseAsync(Expression<Func<T, bool>> predicate, int take, Expression<Func<T, object>> orderByPredicate, OrderByType orderByType, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
|
||||
{
|
||||
@@ -373,7 +373,7 @@ namespace CoreCms.Net.Repository
|
||||
/// <param name="strOrderByFields">排序字段,如name asc,age desc</param>
|
||||
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
|
||||
/// <param name="isDataCache">是否启用缓存</param>
|
||||
/// <param name="cacheTimes">缓存时长(秒)</param>
|
||||
/// <param name="cacheTimes">缓存时长(分钟)</param>
|
||||
/// <returns></returns>
|
||||
public List<T> QueryListByClause(Expression<Func<T, bool>> predicate, int take, string strOrderByFields = "", bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
|
||||
{
|
||||
@@ -401,7 +401,7 @@ namespace CoreCms.Net.Repository
|
||||
/// <param name="strOrderByFields">排序字段,如name asc,age desc</param>
|
||||
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
|
||||
/// <param name="isDataCache">是否启用缓存</param>
|
||||
/// <param name="cacheTimes">缓存时长(秒)</param>
|
||||
/// <param name="cacheTimes">缓存时长(分钟)</param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<T>> QueryListByClauseAsync(Expression<Func<T, bool>> predicate, int take, string strOrderByFields = "", bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
|
||||
{
|
||||
@@ -427,7 +427,7 @@ namespace CoreCms.Net.Repository
|
||||
/// <param name="predicate">条件表达式树</param>
|
||||
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
|
||||
/// <param name="isDataCache">是否启用缓存</param>
|
||||
/// <param name="cacheTimes">缓存时长(秒)</param>
|
||||
/// <param name="cacheTimes">缓存时长(分钟)</param>
|
||||
/// <returns></returns>
|
||||
public T QueryByClause(Expression<Func<T, bool>> predicate, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
|
||||
{
|
||||
@@ -447,7 +447,7 @@ namespace CoreCms.Net.Repository
|
||||
/// <param name="predicate">条件表达式树</param>
|
||||
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
|
||||
/// <param name="isDataCache">是否启用缓存</param>
|
||||
/// <param name="cacheTimes">缓存时长(秒)</param>
|
||||
/// <param name="cacheTimes">缓存时长(分钟)</param>
|
||||
/// <returns></returns>
|
||||
public async Task<T> QueryByClauseAsync(Expression<Func<T, bool>> predicate, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
|
||||
{
|
||||
@@ -469,7 +469,7 @@ namespace CoreCms.Net.Repository
|
||||
/// <param name="orderByType">排序顺序</param>
|
||||
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
|
||||
/// <param name="isDataCache">是否启用缓存</param>
|
||||
/// <param name="cacheTimes">缓存时长(秒)</param>
|
||||
/// <param name="cacheTimes">缓存时长(分钟)</param>
|
||||
/// <returns></returns>
|
||||
public T QueryByClause(Expression<Func<T, bool>> predicate, Expression<Func<T, object>> orderByPredicate, OrderByType orderByType, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
|
||||
{
|
||||
@@ -486,7 +486,7 @@ namespace CoreCms.Net.Repository
|
||||
/// <param name="orderByType">排序顺序</param>
|
||||
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
|
||||
/// <param name="isDataCache">是否启用缓存</param>
|
||||
/// <param name="cacheTimes">缓存时长(秒)</param>
|
||||
/// <param name="cacheTimes">缓存时长(分钟)</param>
|
||||
/// <returns></returns>
|
||||
public async Task<T> QueryByClauseAsync(Expression<Func<T, bool>> predicate, Expression<Func<T, object>> orderByPredicate, OrderByType orderByType, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
|
||||
{
|
||||
@@ -504,7 +504,7 @@ namespace CoreCms.Net.Repository
|
||||
/// <param name="orderByType">排序顺序</param>
|
||||
/// <param name="blUseTranLock">是否使用TranLock</param>
|
||||
/// <param name="isDataCache">是否启用缓存</param>
|
||||
/// <param name="cacheTimes">缓存时长(秒)</param>
|
||||
/// <param name="cacheTimes">缓存时长(分钟)</param>
|
||||
/// <returns></returns>
|
||||
public async Task<T> QueryByClauseWithTranLockAsync(Expression<Func<T, bool>> predicate, Expression<Func<T, object>> orderByPredicate, OrderByType orderByType, bool blUseTranLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
|
||||
{
|
||||
@@ -1146,17 +1146,20 @@ namespace CoreCms.Net.Repository
|
||||
#endregion
|
||||
|
||||
#region 统计数据
|
||||
|
||||
/// <summary>
|
||||
/// 获取数据总数
|
||||
/// </summary>
|
||||
/// <param name="predicate">条件表达式树</param>
|
||||
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
|
||||
/// <param name="isDataCache">是否缓存</param>
|
||||
/// <param name="cacheTimes">缓存时长(分钟)</param>
|
||||
/// <returns></returns>
|
||||
public int GetCount(Expression<Func<T, bool>> predicate, bool blUseNoLock = false)
|
||||
public int GetCount(Expression<Func<T, bool>> predicate, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
|
||||
{
|
||||
return blUseNoLock
|
||||
? DbBaseClient.Queryable<T>().With(SqlWith.NoLock).Count(predicate)
|
||||
: DbBaseClient.Queryable<T>().Count(predicate);
|
||||
? DbBaseClient.Queryable<T>().With(SqlWith.NoLock).WithCacheIF(isDataCache, cacheTimes).Count(predicate)
|
||||
: DbBaseClient.Queryable<T>().WithCacheIF(isDataCache, cacheTimes).Count(predicate);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1164,12 +1167,14 @@ namespace CoreCms.Net.Repository
|
||||
/// </summary>
|
||||
/// <param name="predicate">条件表达式树</param>
|
||||
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
|
||||
/// <param name="isDataCache">是否缓存</param>
|
||||
/// <param name="cacheTimes">缓存时长(分钟)</param>
|
||||
/// <returns></returns>
|
||||
public async Task<int> GetCountAsync(Expression<Func<T, bool>> predicate, bool blUseNoLock = false)
|
||||
public async Task<int> GetCountAsync(Expression<Func<T, bool>> predicate, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
|
||||
{
|
||||
return blUseNoLock
|
||||
? await DbBaseClient.Queryable<T>().With(SqlWith.NoLock).CountAsync(predicate)
|
||||
: await DbBaseClient.Queryable<T>().CountAsync(predicate);
|
||||
? await DbBaseClient.Queryable<T>().With(SqlWith.NoLock).WithCacheIF(isDataCache, cacheTimes).CountAsync(predicate)
|
||||
: await DbBaseClient.Queryable<T>().WithCacheIF(isDataCache, cacheTimes).CountAsync(predicate);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1178,12 +1183,14 @@ namespace CoreCms.Net.Repository
|
||||
/// <param name="predicate">条件表达式树</param>
|
||||
/// <param name="field">字段</param>
|
||||
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
|
||||
/// <param name="isDataCache">是否缓存</param>
|
||||
/// <param name="cacheTimes">缓存时长(分钟)</param>
|
||||
/// <returns></returns>
|
||||
public int GetSum(Expression<Func<T, bool>> predicate, Expression<Func<T, int>> field, bool blUseNoLock = false)
|
||||
public int GetSum(Expression<Func<T, bool>> predicate, Expression<Func<T, int>> field, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
|
||||
{
|
||||
return blUseNoLock
|
||||
? DbBaseClient.Queryable<T>().Where(predicate).With(SqlWith.NoLock).Sum(field)
|
||||
: DbBaseClient.Queryable<T>().Where(predicate).Sum(field);
|
||||
? DbBaseClient.Queryable<T>().Where(predicate).With(SqlWith.NoLock).WithCacheIF(isDataCache, cacheTimes).Sum(field)
|
||||
: DbBaseClient.Queryable<T>().Where(predicate).WithCacheIF(isDataCache, cacheTimes).Sum(field);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1192,13 +1199,15 @@ namespace CoreCms.Net.Repository
|
||||
/// <param name="predicate">条件表达式树</param>
|
||||
/// <param name="field">字段</param>
|
||||
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
|
||||
/// <param name="isDataCache">是否缓存</param>
|
||||
/// <param name="cacheTimes">缓存时长(分钟)</param>
|
||||
/// <returns></returns>
|
||||
public async Task<int> GetSumAsync(Expression<Func<T, bool>> predicate, Expression<Func<T, int>> field,
|
||||
bool blUseNoLock = false)
|
||||
bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
|
||||
{
|
||||
return blUseNoLock
|
||||
? await DbBaseClient.Queryable<T>().Where(predicate).With(SqlWith.NoLock).SumAsync(field)
|
||||
: await DbBaseClient.Queryable<T>().Where(predicate).SumAsync(field);
|
||||
? await DbBaseClient.Queryable<T>().Where(predicate).With(SqlWith.NoLock).WithCacheIF(isDataCache, cacheTimes).SumAsync(field)
|
||||
: await DbBaseClient.Queryable<T>().Where(predicate).WithCacheIF(isDataCache, cacheTimes).SumAsync(field);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1207,13 +1216,15 @@ namespace CoreCms.Net.Repository
|
||||
/// <param name="predicate">条件表达式树</param>
|
||||
/// <param name="field">字段</param>
|
||||
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
|
||||
/// <param name="isDataCache">是否缓存</param>
|
||||
/// <param name="cacheTimes">缓存时长(分钟)</param>
|
||||
/// <returns></returns>
|
||||
public decimal GetSum(Expression<Func<T, bool>> predicate, Expression<Func<T, decimal>> field,
|
||||
bool blUseNoLock = false)
|
||||
bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
|
||||
{
|
||||
return blUseNoLock
|
||||
? DbBaseClient.Queryable<T>().Where(predicate).With(SqlWith.NoLock).Sum(field)
|
||||
: DbBaseClient.Queryable<T>().Where(predicate).Sum(field);
|
||||
? DbBaseClient.Queryable<T>().Where(predicate).With(SqlWith.NoLock).WithCacheIF(isDataCache, cacheTimes).Sum(field)
|
||||
: DbBaseClient.Queryable<T>().Where(predicate).WithCacheIF(isDataCache, cacheTimes).Sum(field);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1222,13 +1233,15 @@ namespace CoreCms.Net.Repository
|
||||
/// <param name="predicate">条件表达式树</param>
|
||||
/// <param name="field">字段</param>
|
||||
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
|
||||
/// <param name="isDataCache">是否缓存</param>
|
||||
/// <param name="cacheTimes">缓存时长(分钟)</param>
|
||||
/// <returns></returns>
|
||||
public async Task<decimal> GetSumAsync(Expression<Func<T, bool>> predicate, Expression<Func<T, decimal>> field,
|
||||
bool blUseNoLock = false)
|
||||
bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
|
||||
{
|
||||
return blUseNoLock
|
||||
? await DbBaseClient.Queryable<T>().Where(predicate).With(SqlWith.NoLock).SumAsync(field)
|
||||
: await DbBaseClient.Queryable<T>().Where(predicate).SumAsync(field);
|
||||
? await DbBaseClient.Queryable<T>().Where(predicate).With(SqlWith.NoLock).WithCacheIF(isDataCache, cacheTimes).SumAsync(field)
|
||||
: await DbBaseClient.Queryable<T>().Where(predicate).WithCacheIF(isDataCache, cacheTimes).SumAsync(field);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1237,13 +1250,15 @@ namespace CoreCms.Net.Repository
|
||||
/// <param name="predicate">条件表达式树</param>
|
||||
/// <param name="field">字段</param>
|
||||
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
|
||||
/// <param name="isDataCache">是否缓存</param>
|
||||
/// <param name="cacheTimes">缓存时长(分钟)</param>
|
||||
/// <returns></returns>
|
||||
public float GetSum(Expression<Func<T, bool>> predicate, Expression<Func<T, float>> field,
|
||||
bool blUseNoLock = false)
|
||||
bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
|
||||
{
|
||||
return blUseNoLock
|
||||
? DbBaseClient.Queryable<T>().Where(predicate).With(SqlWith.NoLock).Sum(field)
|
||||
: DbBaseClient.Queryable<T>().Where(predicate).Sum(field);
|
||||
? DbBaseClient.Queryable<T>().Where(predicate).With(SqlWith.NoLock).WithCacheIF(isDataCache, cacheTimes).Sum(field)
|
||||
: DbBaseClient.Queryable<T>().Where(predicate).WithCacheIF(isDataCache, cacheTimes).Sum(field);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1252,13 +1267,15 @@ namespace CoreCms.Net.Repository
|
||||
/// <param name="predicate">条件表达式树</param>
|
||||
/// <param name="field">字段</param>
|
||||
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
|
||||
/// <param name="isDataCache">是否缓存</param>
|
||||
/// <param name="cacheTimes">缓存时长(分钟)</param>
|
||||
/// <returns></returns>
|
||||
public async Task<float> GetSumAsync(Expression<Func<T, bool>> predicate, Expression<Func<T, float>> field,
|
||||
bool blUseNoLock = false)
|
||||
bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
|
||||
{
|
||||
return blUseNoLock
|
||||
? await DbBaseClient.Queryable<T>().Where(predicate).With(SqlWith.NoLock).SumAsync(field)
|
||||
: await DbBaseClient.Queryable<T>().Where(predicate).SumAsync(field);
|
||||
? await DbBaseClient.Queryable<T>().Where(predicate).With(SqlWith.NoLock).WithCacheIF(isDataCache, cacheTimes).SumAsync(field)
|
||||
: await DbBaseClient.Queryable<T>().Where(predicate).WithCacheIF(isDataCache, cacheTimes).SumAsync(field);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -1273,7 +1290,7 @@ namespace CoreCms.Net.Repository
|
||||
/// <param name="pageSize">分布大小</param>
|
||||
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
|
||||
/// <param name="isDataCache">是否启用缓存</param>
|
||||
/// <param name="cacheTimes">缓存时长(秒)</param>
|
||||
/// <param name="cacheTimes">缓存时长(分钟)</param>
|
||||
/// <returns></returns>
|
||||
public IPageList<T> QueryPage(Expression<Func<T, bool>> predicate, string orderBy = "", int pageIndex = 1,
|
||||
int pageSize = 20, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
|
||||
@@ -1306,7 +1323,7 @@ namespace CoreCms.Net.Repository
|
||||
/// <param name="pageSize">分布大小</param>
|
||||
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
|
||||
/// <param name="isDataCache">是否启用缓存</param>
|
||||
/// <param name="cacheTimes">缓存时长(秒)</param>
|
||||
/// <param name="cacheTimes">缓存时长(分钟)</param>
|
||||
/// <returns></returns>
|
||||
public async Task<IPageList<T>> QueryPageAsync(Expression<Func<T, bool>> predicate, string orderBy = "",
|
||||
int pageIndex = 1, int pageSize = 20, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
|
||||
@@ -1338,7 +1355,7 @@ namespace CoreCms.Net.Repository
|
||||
/// <param name="orderByExpression"></param>
|
||||
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
|
||||
/// <param name="isDataCache">是否启用缓存</param>
|
||||
/// <param name="cacheTimes">缓存时长(秒)</param>
|
||||
/// <param name="cacheTimes">缓存时长(分钟)</param>
|
||||
/// <returns></returns>
|
||||
public IPageList<T> QueryPage(Expression<Func<T, bool>> predicate,
|
||||
Expression<Func<T, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||
@@ -1371,7 +1388,7 @@ namespace CoreCms.Net.Repository
|
||||
/// <param name="orderByExpression"></param>
|
||||
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
|
||||
/// <param name="isDataCache">是否启用缓存</param>
|
||||
/// <param name="cacheTimes">缓存时长(秒)</param>
|
||||
/// <param name="cacheTimes">缓存时长(分钟)</param>
|
||||
/// <returns></returns>
|
||||
public async Task<IPageList<T>> QueryPageAsync(Expression<Func<T, bool>> predicate,
|
||||
Expression<Func<T, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
||||
@@ -1408,7 +1425,7 @@ namespace CoreCms.Net.Repository
|
||||
/// <param name="whereLambda">查询表达式 (w1, w2) =>w1.UserNo == "")</param>
|
||||
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
|
||||
/// <param name="isDataCache">是否启用缓存</param>
|
||||
/// <param name="cacheTimes">缓存时长(秒)</param>
|
||||
/// <param name="cacheTimes">缓存时长(分钟)</param>
|
||||
/// <returns>值</returns>
|
||||
public List<TResult> QueryMuch<T1, T2, TResult>(
|
||||
Expression<Func<T1, T2, object[]>> joinExpression,
|
||||
@@ -1436,7 +1453,7 @@ namespace CoreCms.Net.Repository
|
||||
/// <param name="whereLambda">查询表达式 (w1, w2) =>w1.UserNo == "")</param>
|
||||
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
|
||||
/// <param name="isDataCache">是否启用缓存</param>
|
||||
/// <param name="cacheTimes">缓存时长(秒)</param>
|
||||
/// <param name="cacheTimes">缓存时长(分钟)</param>
|
||||
/// <returns>值</returns>
|
||||
public async Task<List<TResult>> QueryMuchAsync<T1, T2, TResult>(
|
||||
Expression<Func<T1, T2, object[]>> joinExpression,
|
||||
@@ -1464,7 +1481,7 @@ namespace CoreCms.Net.Repository
|
||||
/// <param name="whereLambda">查询表达式 (w1, w2) =>w1.UserNo == "")</param>
|
||||
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
|
||||
/// <param name="isDataCache">是否启用缓存</param>
|
||||
/// <param name="cacheTimes">缓存时长(秒)</param>
|
||||
/// <param name="cacheTimes">缓存时长(分钟)</param>
|
||||
/// <returns>值</returns>
|
||||
public TResult QueryMuchFirst<T1, T2, TResult>(
|
||||
Expression<Func<T1, T2, object[]>> joinExpression,
|
||||
@@ -1492,7 +1509,7 @@ namespace CoreCms.Net.Repository
|
||||
/// <param name="whereLambda">查询表达式 (w1, w2) =>w1.UserNo == "")</param>
|
||||
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
|
||||
/// <param name="isDataCache">是否启用缓存</param>
|
||||
/// <param name="cacheTimes">缓存时长(秒)</param>
|
||||
/// <param name="cacheTimes">缓存时长(分钟)</param>
|
||||
/// <returns>值</returns>
|
||||
public async Task<TResult> QueryMuchFirstAsync<T1, T2, TResult>(
|
||||
Expression<Func<T1, T2, object[]>> joinExpression,
|
||||
@@ -1521,7 +1538,7 @@ namespace CoreCms.Net.Repository
|
||||
/// <param name="whereLambda">查询表达式 (w1, w2) =>w1.UserNo == "")</param>
|
||||
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
|
||||
/// <param name="isDataCache">是否启用缓存</param>
|
||||
/// <param name="cacheTimes">缓存时长(秒)</param>
|
||||
/// <param name="cacheTimes">缓存时长(分钟)</param>
|
||||
/// <returns>值</returns>
|
||||
public List<TResult> QueryMuch<T1, T2, T3, TResult>(
|
||||
Expression<Func<T1, T2, T3, object[]>> joinExpression,
|
||||
@@ -1550,7 +1567,7 @@ namespace CoreCms.Net.Repository
|
||||
/// <param name="whereLambda">查询表达式 (w1, w2) =>w1.UserNo == "")</param>
|
||||
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
|
||||
/// <param name="isDataCache">是否启用缓存</param>
|
||||
/// <param name="cacheTimes">缓存时长(秒)</param>
|
||||
/// <param name="cacheTimes">缓存时长(分钟)</param>
|
||||
/// <returns>值</returns>
|
||||
public async Task<List<TResult>> QueryMuchAsync<T1, T2, T3, TResult>(
|
||||
Expression<Func<T1, T2, T3, object[]>> joinExpression,
|
||||
@@ -1589,7 +1606,7 @@ namespace CoreCms.Net.Repository
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="sql"></param>
|
||||
/// <param name="isDataCache">是否启用缓存</param>
|
||||
/// <param name="cacheTimes">缓存时长(秒)</param>
|
||||
/// <param name="cacheTimes">缓存时长(分钟)</param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<T>> SqlQueryable(string sql, bool isDataCache = false, int cacheTimes = int.MaxValue)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user