mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2025-12-06 16:03:25 +08:00
【修复】修复后台支付单生成校验失败的问题。
【优化】新增SqlSugarExtensions扩展类,增加是否使用WITH(NoLock)方法扩展封装,删除BaseRepository中的一些冗余代码。
This commit is contained in:
@@ -47,9 +47,7 @@ namespace CoreCms.Net.Repository
|
||||
/// <returns>泛型实体</returns>
|
||||
public T QueryById(object pkValue, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
|
||||
{
|
||||
return blUseNoLock
|
||||
? DbBaseClient.Queryable<T>().With(SqlWith.NoLock).WithCacheIF(isDataCache, cacheTimes).InSingle(pkValue)
|
||||
: DbBaseClient.Queryable<T>().WithCacheIF(isDataCache, cacheTimes).InSingle(pkValue);
|
||||
return DbBaseClient.Queryable<T>().WithNoLockOrNot(blUseNoLock).WithCacheIF(isDataCache, cacheTimes).InSingle(pkValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -62,9 +60,7 @@ namespace CoreCms.Net.Repository
|
||||
/// <returns>数据实体</returns>
|
||||
public async Task<T> QueryByIdAsync(object objId, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
|
||||
{
|
||||
return blUseNoLock
|
||||
? await DbBaseClient.Queryable<T>().In(objId).With(SqlWith.NoLock).WithCacheIF(isDataCache, cacheTimes).SingleAsync()
|
||||
: await DbBaseClient.Queryable<T>().In(objId).WithCacheIF(isDataCache, cacheTimes).SingleAsync();
|
||||
return await DbBaseClient.Queryable<T>().In(objId).WithNoLockOrNot(blUseNoLock).WithCacheIF(isDataCache, cacheTimes).SingleAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -77,9 +73,7 @@ namespace CoreCms.Net.Repository
|
||||
/// <param name="cacheTimes">缓存时长(分钟)</param>
|
||||
public List<T> QueryByIDs(object[] lstIds, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
|
||||
{
|
||||
return blUseNoLock
|
||||
? DbBaseClient.Queryable<T>().In(lstIds).With(SqlWith.NoLock).WithCacheIF(isDataCache, cacheTimes).ToList()
|
||||
: DbBaseClient.Queryable<T>().In(lstIds).WithCacheIF(isDataCache, cacheTimes).ToList();
|
||||
return DbBaseClient.Queryable<T>().In(lstIds).WithNoLockOrNot(blUseNoLock).WithCacheIF(isDataCache, cacheTimes).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -92,9 +86,7 @@ namespace CoreCms.Net.Repository
|
||||
/// <param name="cacheTimes">缓存时长(分钟)</param>
|
||||
public async Task<List<T>> QueryByIDsAsync(object[] lstIds, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
|
||||
{
|
||||
return blUseNoLock
|
||||
? await DbBaseClient.Queryable<T>().In(lstIds).With(SqlWith.NoLock).WithCacheIF(isDataCache, cacheTimes).ToListAsync()
|
||||
: await DbBaseClient.Queryable<T>().In(lstIds).WithCacheIF(isDataCache, cacheTimes).ToListAsync();
|
||||
return await DbBaseClient.Queryable<T>().In(lstIds).WithNoLockOrNot(blUseNoLock).WithCacheIF(isDataCache, cacheTimes).ToListAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -107,9 +99,7 @@ namespace CoreCms.Net.Repository
|
||||
/// <param name="cacheTimes">缓存时长(分钟)</param>
|
||||
public List<T> QueryByIDs(int[] lstIds, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
|
||||
{
|
||||
return blUseNoLock
|
||||
? DbBaseClient.Queryable<T>().In(lstIds).With(SqlWith.NoLock).WithCacheIF(isDataCache, cacheTimes).ToList()
|
||||
: DbBaseClient.Queryable<T>().In(lstIds).WithCacheIF(isDataCache, cacheTimes).ToList();
|
||||
return DbBaseClient.Queryable<T>().In(lstIds).WithNoLockOrNot(blUseNoLock).WithCacheIF(isDataCache, cacheTimes).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -122,9 +112,7 @@ namespace CoreCms.Net.Repository
|
||||
/// <param name="cacheTimes">缓存时长(分钟)</param>
|
||||
public async Task<List<T>> QueryByIDsAsync(int[] lstIds, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
|
||||
{
|
||||
return blUseNoLock
|
||||
? await DbBaseClient.Queryable<T>().In(lstIds).With(SqlWith.NoLock).WithCacheIF(isDataCache, cacheTimes).ToListAsync()
|
||||
: await DbBaseClient.Queryable<T>().In(lstIds).WithCacheIF(isDataCache, cacheTimes).ToListAsync();
|
||||
return await DbBaseClient.Queryable<T>().In(lstIds).WithNoLockOrNot(blUseNoLock).WithCacheIF(isDataCache, cacheTimes).ToListAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -136,9 +124,7 @@ namespace CoreCms.Net.Repository
|
||||
/// <returns></returns>
|
||||
public List<T> Query(bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
|
||||
{
|
||||
return blUseNoLock
|
||||
? DbBaseClient.Queryable<T>().With(SqlWith.NoLock).WithCacheIF(isDataCache, cacheTimes).ToList()
|
||||
: DbBaseClient.Queryable<T>().WithCacheIF(isDataCache, cacheTimes).ToList();
|
||||
return DbBaseClient.Queryable<T>().WithNoLockOrNot(blUseNoLock).WithCacheIF(isDataCache, cacheTimes).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -150,9 +136,7 @@ namespace CoreCms.Net.Repository
|
||||
/// <returns></returns>
|
||||
public async Task<List<T>> QueryAsync(bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
|
||||
{
|
||||
return blUseNoLock
|
||||
? await DbBaseClient.Queryable<T>().With(SqlWith.NoLock).WithCacheIF(isDataCache, cacheTimes).ToListAsync()
|
||||
: await DbBaseClient.Queryable<T>().WithCacheIF(isDataCache, cacheTimes).ToListAsync();
|
||||
return await DbBaseClient.Queryable<T>().WithNoLockOrNot(blUseNoLock).WithCacheIF(isDataCache, cacheTimes).ToListAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -166,18 +150,12 @@ namespace CoreCms.Net.Repository
|
||||
/// <returns>泛型实体集合</returns>
|
||||
public List<T> QueryListByClause(string strWhere, string orderBy = "", bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
|
||||
{
|
||||
return blUseNoLock
|
||||
? DbBaseClient.Queryable<T>()
|
||||
.OrderByIF(!string.IsNullOrEmpty(orderBy), orderBy)
|
||||
.WhereIF(!string.IsNullOrEmpty(strWhere), strWhere)
|
||||
.With(SqlWith.NoLock)
|
||||
.WithCacheIF(isDataCache, cacheTimes)
|
||||
.ToList()
|
||||
: DbBaseClient.Queryable<T>()
|
||||
.OrderByIF(!string.IsNullOrEmpty(orderBy), orderBy)
|
||||
.WhereIF(!string.IsNullOrEmpty(strWhere), strWhere)
|
||||
.WithCacheIF(isDataCache, cacheTimes)
|
||||
.ToList();
|
||||
return DbBaseClient.Queryable<T>()
|
||||
.OrderByIF(!string.IsNullOrEmpty(orderBy), orderBy)
|
||||
.WhereIF(!string.IsNullOrEmpty(strWhere), strWhere)
|
||||
.WithNoLockOrNot(blUseNoLock)
|
||||
.WithCacheIF(isDataCache, cacheTimes)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -191,18 +169,12 @@ namespace CoreCms.Net.Repository
|
||||
/// <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
|
||||
? await DbBaseClient.Queryable<T>()
|
||||
.OrderByIF(!string.IsNullOrEmpty(orderBy), orderBy)
|
||||
.WhereIF(!string.IsNullOrEmpty(strWhere), strWhere)
|
||||
.With(SqlWith.NoLock)
|
||||
.WithCacheIF(isDataCache, cacheTimes)
|
||||
.ToListAsync()
|
||||
: await DbBaseClient.Queryable<T>()
|
||||
.OrderByIF(!string.IsNullOrEmpty(orderBy), orderBy)
|
||||
.WhereIF(!string.IsNullOrEmpty(strWhere), strWhere)
|
||||
.WithCacheIF(isDataCache, cacheTimes)
|
||||
.ToListAsync();
|
||||
return await DbBaseClient.Queryable<T>()
|
||||
.OrderByIF(!string.IsNullOrEmpty(orderBy), orderBy)
|
||||
.WhereIF(!string.IsNullOrEmpty(strWhere), strWhere)
|
||||
.WithNoLockOrNot(blUseNoLock)
|
||||
.WithCacheIF(isDataCache, cacheTimes)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -216,18 +188,12 @@ namespace CoreCms.Net.Repository
|
||||
/// <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
|
||||
? DbBaseClient.Queryable<T>()
|
||||
.OrderByIF(!string.IsNullOrEmpty(orderBy), orderBy)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.With(SqlWith.NoLock)
|
||||
.WithCacheIF(isDataCache, cacheTimes)
|
||||
.ToList()
|
||||
: DbBaseClient.Queryable<T>()
|
||||
.OrderByIF(!string.IsNullOrEmpty(orderBy), orderBy)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.WithCacheIF(isDataCache, cacheTimes)
|
||||
.ToList();
|
||||
return DbBaseClient.Queryable<T>()
|
||||
.OrderByIF(!string.IsNullOrEmpty(orderBy), orderBy)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.WithNoLockOrNot(blUseNoLock)
|
||||
.WithCacheIF(isDataCache, cacheTimes)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -241,18 +207,12 @@ namespace CoreCms.Net.Repository
|
||||
/// <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
|
||||
? await DbBaseClient.Queryable<T>()
|
||||
.OrderByIF(!string.IsNullOrEmpty(orderBy), orderBy)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.With(SqlWith.NoLock)
|
||||
.WithCacheIF(isDataCache, cacheTimes)
|
||||
.ToListAsync()
|
||||
: await DbBaseClient.Queryable<T>()
|
||||
.OrderByIF(!string.IsNullOrEmpty(orderBy), orderBy)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.WithCacheIF(isDataCache, cacheTimes)
|
||||
.ToListAsync();
|
||||
return await DbBaseClient.Queryable<T>()
|
||||
.OrderByIF(!string.IsNullOrEmpty(orderBy), orderBy)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.WithNoLockOrNot(blUseNoLock)
|
||||
.WithCacheIF(isDataCache, cacheTimes)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -267,18 +227,12 @@ namespace CoreCms.Net.Repository
|
||||
/// <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)
|
||||
{
|
||||
return blUseNoLock
|
||||
? DbBaseClient.Queryable<T>()
|
||||
.OrderByIF(orderByPredicate != null, orderByPredicate, orderByType)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.With(SqlWith.NoLock)
|
||||
.WithCacheIF(isDataCache, cacheTimes)
|
||||
.ToList()
|
||||
: DbBaseClient.Queryable<T>()
|
||||
.OrderByIF(orderByPredicate != null, orderByPredicate, orderByType)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.WithCacheIF(isDataCache, cacheTimes)
|
||||
.ToList();
|
||||
return DbBaseClient.Queryable<T>()
|
||||
.OrderByIF(orderByPredicate != null, orderByPredicate, orderByType)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.WithNoLockOrNot(blUseNoLock)
|
||||
.WithCacheIF(isDataCache, cacheTimes)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -293,18 +247,12 @@ namespace CoreCms.Net.Repository
|
||||
/// <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)
|
||||
{
|
||||
return blUseNoLock
|
||||
? await DbBaseClient.Queryable<T>()
|
||||
.OrderByIF(orderByPredicate != null, orderByPredicate, orderByType)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.With(SqlWith.NoLock)
|
||||
.WithCacheIF(isDataCache, cacheTimes)
|
||||
.ToListAsync()
|
||||
: await DbBaseClient.Queryable<T>()
|
||||
.OrderByIF(orderByPredicate != null, orderByPredicate, orderByType)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.WithCacheIF(isDataCache, cacheTimes)
|
||||
.ToListAsync();
|
||||
return await DbBaseClient.Queryable<T>()
|
||||
.OrderByIF(orderByPredicate != null, orderByPredicate, orderByType)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.WithNoLockOrNot(blUseNoLock)
|
||||
.WithCacheIF(isDataCache, cacheTimes)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -320,20 +268,13 @@ namespace CoreCms.Net.Repository
|
||||
/// <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)
|
||||
{
|
||||
return blUseNoLock
|
||||
? DbBaseClient.Queryable<T>()
|
||||
.OrderByIF(orderByPredicate != null, orderByPredicate, orderByType)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.Take(take)
|
||||
.With(SqlWith.NoLock)
|
||||
.WithCacheIF(isDataCache, cacheTimes)
|
||||
.ToList()
|
||||
: DbBaseClient.Queryable<T>()
|
||||
.OrderByIF(orderByPredicate != null, orderByPredicate, orderByType)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.Take(take)
|
||||
.WithCacheIF(isDataCache, cacheTimes)
|
||||
.ToList();
|
||||
return DbBaseClient.Queryable<T>()
|
||||
.OrderByIF(orderByPredicate != null, orderByPredicate, orderByType)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.Take(take)
|
||||
.WithNoLockOrNot(blUseNoLock)
|
||||
.WithCacheIF(isDataCache, cacheTimes)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -349,20 +290,13 @@ namespace CoreCms.Net.Repository
|
||||
/// <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)
|
||||
{
|
||||
return blUseNoLock
|
||||
? await DbBaseClient.Queryable<T>()
|
||||
.OrderByIF(orderByPredicate != null, orderByPredicate, orderByType)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.Take(take)
|
||||
.With(SqlWith.NoLock)
|
||||
.WithCacheIF(isDataCache, cacheTimes)
|
||||
.ToListAsync()
|
||||
: await DbBaseClient.Queryable<T>()
|
||||
.OrderByIF(orderByPredicate != null, orderByPredicate, orderByType)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.Take(take)
|
||||
.WithCacheIF(isDataCache, cacheTimes)
|
||||
.ToListAsync();
|
||||
return await DbBaseClient.Queryable<T>()
|
||||
.OrderByIF(orderByPredicate != null, orderByPredicate, orderByType)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.Take(take)
|
||||
.WithNoLockOrNot(blUseNoLock)
|
||||
.WithCacheIF(isDataCache, cacheTimes)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -377,20 +311,13 @@ namespace CoreCms.Net.Repository
|
||||
/// <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)
|
||||
{
|
||||
return blUseNoLock
|
||||
? DbBaseClient.Queryable<T>()
|
||||
.OrderByIF(!string.IsNullOrEmpty(strOrderByFields), strOrderByFields)
|
||||
.Where(predicate)
|
||||
.Take(take)
|
||||
.With(SqlWith.NoLock)
|
||||
.WithCacheIF(isDataCache, cacheTimes)
|
||||
.ToList()
|
||||
: DbBaseClient.Queryable<T>()
|
||||
.OrderByIF(!string.IsNullOrEmpty(strOrderByFields), strOrderByFields)
|
||||
.Where(predicate)
|
||||
.Take(take)
|
||||
.WithCacheIF(isDataCache, cacheTimes)
|
||||
.ToList();
|
||||
return DbBaseClient.Queryable<T>()
|
||||
.OrderByIF(!string.IsNullOrEmpty(strOrderByFields), strOrderByFields)
|
||||
.Where(predicate)
|
||||
.Take(take)
|
||||
.WithNoLockOrNot(blUseNoLock)
|
||||
.WithCacheIF(isDataCache, cacheTimes)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -405,20 +332,13 @@ namespace CoreCms.Net.Repository
|
||||
/// <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)
|
||||
{
|
||||
return blUseNoLock
|
||||
? await DbBaseClient.Queryable<T>()
|
||||
.OrderByIF(!string.IsNullOrEmpty(strOrderByFields), strOrderByFields)
|
||||
.Where(predicate)
|
||||
.Take(take)
|
||||
.With(SqlWith.NoLock)
|
||||
.WithCacheIF(isDataCache, cacheTimes)
|
||||
.ToListAsync()
|
||||
: await DbBaseClient.Queryable<T>()
|
||||
.OrderByIF(!string.IsNullOrEmpty(strOrderByFields), strOrderByFields)
|
||||
.Where(predicate)
|
||||
.Take(take)
|
||||
.WithCacheIF(isDataCache, cacheTimes)
|
||||
.ToListAsync();
|
||||
return await DbBaseClient.Queryable<T>()
|
||||
.OrderByIF(!string.IsNullOrEmpty(strOrderByFields), strOrderByFields)
|
||||
.Where(predicate)
|
||||
.Take(take)
|
||||
.WithNoLockOrNot(blUseNoLock)
|
||||
.WithCacheIF(isDataCache, cacheTimes)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -431,14 +351,10 @@ namespace CoreCms.Net.Repository
|
||||
/// <returns></returns>
|
||||
public T QueryByClause(Expression<Func<T, bool>> predicate, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
|
||||
{
|
||||
return blUseNoLock
|
||||
? DbBaseClient.Queryable<T>()
|
||||
.With(SqlWith.NoLock)
|
||||
.WithCacheIF(isDataCache, cacheTimes)
|
||||
.First(predicate)
|
||||
: DbBaseClient.Queryable<T>()
|
||||
.WithCacheIF(isDataCache, cacheTimes)
|
||||
.First(predicate);
|
||||
return DbBaseClient.Queryable<T>()
|
||||
.WithNoLockOrNot(blUseNoLock)
|
||||
.WithCacheIF(isDataCache, cacheTimes)
|
||||
.First(predicate);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -451,14 +367,10 @@ namespace CoreCms.Net.Repository
|
||||
/// <returns></returns>
|
||||
public async Task<T> QueryByClauseAsync(Expression<Func<T, bool>> predicate, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
|
||||
{
|
||||
return blUseNoLock
|
||||
? await DbBaseClient.Queryable<T>()
|
||||
.With(SqlWith.NoLock)
|
||||
.WithCacheIF(isDataCache, cacheTimes)
|
||||
.FirstAsync(predicate)
|
||||
: await DbBaseClient.Queryable<T>()
|
||||
.WithCacheIF(isDataCache, cacheTimes)
|
||||
.FirstAsync(predicate);
|
||||
return await DbBaseClient.Queryable<T>()
|
||||
.WithNoLockOrNot(blUseNoLock)
|
||||
.WithCacheIF(isDataCache, cacheTimes)
|
||||
.FirstAsync(predicate);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -473,9 +385,7 @@ namespace CoreCms.Net.Repository
|
||||
/// <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)
|
||||
{
|
||||
return blUseNoLock
|
||||
? DbBaseClient.Queryable<T>().OrderBy(orderByPredicate, orderByType).With(SqlWith.NoLock).WithCacheIF(isDataCache, cacheTimes).First(predicate)
|
||||
: DbBaseClient.Queryable<T>().OrderBy(orderByPredicate, orderByType).WithCacheIF(isDataCache, cacheTimes).First(predicate);
|
||||
return DbBaseClient.Queryable<T>().OrderBy(orderByPredicate, orderByType).WithNoLockOrNot(blUseNoLock).WithCacheIF(isDataCache, cacheTimes).First(predicate);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -490,9 +400,7 @@ namespace CoreCms.Net.Repository
|
||||
/// <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)
|
||||
{
|
||||
return blUseNoLock
|
||||
? await DbBaseClient.Queryable<T>().OrderBy(orderByPredicate, orderByType).With(SqlWith.NoLock).WithCacheIF(isDataCache, cacheTimes).FirstAsync(predicate)
|
||||
: await DbBaseClient.Queryable<T>().OrderBy(orderByPredicate, orderByType).WithCacheIF(isDataCache, cacheTimes).FirstAsync(predicate);
|
||||
return await DbBaseClient.Queryable<T>().OrderBy(orderByPredicate, orderByType).WithNoLockOrNot(blUseNoLock).WithCacheIF(isDataCache, cacheTimes).FirstAsync(predicate);
|
||||
}
|
||||
|
||||
|
||||
@@ -508,9 +416,7 @@ namespace CoreCms.Net.Repository
|
||||
/// <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)
|
||||
{
|
||||
return blUseTranLock
|
||||
? await DbBaseClient.Queryable<T>().TranLock(DbLockType.Wait).OrderBy(orderByPredicate, orderByType).WithCacheIF(isDataCache, cacheTimes).FirstAsync(predicate)
|
||||
: await DbBaseClient.Queryable<T>().OrderBy(orderByPredicate, orderByType).WithCacheIF(isDataCache, cacheTimes).FirstAsync(predicate);
|
||||
return await DbBaseClient.Queryable<T>().TranLock(DbLockType.Wait).OrderBy(orderByPredicate, orderByType).WithCacheIF(isDataCache, cacheTimes).FirstAsync(predicate);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -1125,9 +1031,7 @@ namespace CoreCms.Net.Repository
|
||||
/// <returns></returns>
|
||||
public bool Exists(Expression<Func<T, bool>> predicate, bool blUseNoLock = false)
|
||||
{
|
||||
return blUseNoLock
|
||||
? DbBaseClient.Queryable<T>().Where(predicate).With(SqlWith.NoLock).Any()
|
||||
: DbBaseClient.Queryable<T>().Where(predicate).Any();
|
||||
return DbBaseClient.Queryable<T>().Where(predicate).WithNoLockOrNot(blUseNoLock).Any();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1138,9 +1042,7 @@ namespace CoreCms.Net.Repository
|
||||
/// <returns></returns>
|
||||
public async Task<bool> ExistsAsync(Expression<Func<T, bool>> predicate, bool blUseNoLock = false)
|
||||
{
|
||||
return blUseNoLock
|
||||
? await DbBaseClient.Queryable<T>().Where(predicate).With(SqlWith.NoLock).AnyAsync()
|
||||
: await DbBaseClient.Queryable<T>().Where(predicate).AnyAsync();
|
||||
return await DbBaseClient.Queryable<T>().Where(predicate).WithNoLockOrNot(blUseNoLock).AnyAsync();
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -1158,7 +1060,7 @@ namespace CoreCms.Net.Repository
|
||||
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).WithCacheIF(isDataCache, cacheTimes).Count(predicate)
|
||||
? DbBaseClient.Queryable<T>().WithNoLockOrNot(blUseNoLock).WithCacheIF(isDataCache, cacheTimes).Count(predicate)
|
||||
: DbBaseClient.Queryable<T>().WithCacheIF(isDataCache, cacheTimes).Count(predicate);
|
||||
}
|
||||
|
||||
@@ -1173,7 +1075,7 @@ namespace CoreCms.Net.Repository
|
||||
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).WithCacheIF(isDataCache, cacheTimes).CountAsync(predicate)
|
||||
? await DbBaseClient.Queryable<T>().WithNoLockOrNot(blUseNoLock).WithCacheIF(isDataCache, cacheTimes).CountAsync(predicate)
|
||||
: await DbBaseClient.Queryable<T>().WithCacheIF(isDataCache, cacheTimes).CountAsync(predicate);
|
||||
}
|
||||
|
||||
@@ -1189,7 +1091,7 @@ namespace CoreCms.Net.Repository
|
||||
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).WithCacheIF(isDataCache, cacheTimes).Sum(field)
|
||||
? DbBaseClient.Queryable<T>().Where(predicate).WithNoLockOrNot(blUseNoLock).WithCacheIF(isDataCache, cacheTimes).Sum(field)
|
||||
: DbBaseClient.Queryable<T>().Where(predicate).WithCacheIF(isDataCache, cacheTimes).Sum(field);
|
||||
}
|
||||
|
||||
@@ -1206,7 +1108,7 @@ namespace CoreCms.Net.Repository
|
||||
bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
|
||||
{
|
||||
return blUseNoLock
|
||||
? await DbBaseClient.Queryable<T>().Where(predicate).With(SqlWith.NoLock).WithCacheIF(isDataCache, cacheTimes).SumAsync(field)
|
||||
? await DbBaseClient.Queryable<T>().Where(predicate).WithNoLockOrNot(blUseNoLock).WithCacheIF(isDataCache, cacheTimes).SumAsync(field)
|
||||
: await DbBaseClient.Queryable<T>().Where(predicate).WithCacheIF(isDataCache, cacheTimes).SumAsync(field);
|
||||
}
|
||||
|
||||
@@ -1223,7 +1125,7 @@ namespace CoreCms.Net.Repository
|
||||
bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
|
||||
{
|
||||
return blUseNoLock
|
||||
? DbBaseClient.Queryable<T>().Where(predicate).With(SqlWith.NoLock).WithCacheIF(isDataCache, cacheTimes).Sum(field)
|
||||
? DbBaseClient.Queryable<T>().Where(predicate).WithNoLockOrNot(blUseNoLock).WithCacheIF(isDataCache, cacheTimes).Sum(field)
|
||||
: DbBaseClient.Queryable<T>().Where(predicate).WithCacheIF(isDataCache, cacheTimes).Sum(field);
|
||||
}
|
||||
|
||||
@@ -1240,7 +1142,7 @@ namespace CoreCms.Net.Repository
|
||||
bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
|
||||
{
|
||||
return blUseNoLock
|
||||
? await DbBaseClient.Queryable<T>().Where(predicate).With(SqlWith.NoLock).WithCacheIF(isDataCache, cacheTimes).SumAsync(field)
|
||||
? await DbBaseClient.Queryable<T>().Where(predicate).WithNoLockOrNot(blUseNoLock).WithCacheIF(isDataCache, cacheTimes).SumAsync(field)
|
||||
: await DbBaseClient.Queryable<T>().Where(predicate).WithCacheIF(isDataCache, cacheTimes).SumAsync(field);
|
||||
}
|
||||
|
||||
@@ -1257,7 +1159,7 @@ namespace CoreCms.Net.Repository
|
||||
bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
|
||||
{
|
||||
return blUseNoLock
|
||||
? DbBaseClient.Queryable<T>().Where(predicate).With(SqlWith.NoLock).WithCacheIF(isDataCache, cacheTimes).Sum(field)
|
||||
? DbBaseClient.Queryable<T>().Where(predicate).WithNoLockOrNot(blUseNoLock).WithCacheIF(isDataCache, cacheTimes).Sum(field)
|
||||
: DbBaseClient.Queryable<T>().Where(predicate).WithCacheIF(isDataCache, cacheTimes).Sum(field);
|
||||
}
|
||||
|
||||
@@ -1274,7 +1176,7 @@ namespace CoreCms.Net.Repository
|
||||
bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
|
||||
{
|
||||
return blUseNoLock
|
||||
? await DbBaseClient.Queryable<T>().Where(predicate).With(SqlWith.NoLock).WithCacheIF(isDataCache, cacheTimes).SumAsync(field)
|
||||
? await DbBaseClient.Queryable<T>().Where(predicate).WithNoLockOrNot(blUseNoLock).WithCacheIF(isDataCache, cacheTimes).SumAsync(field)
|
||||
: await DbBaseClient.Queryable<T>().Where(predicate).WithCacheIF(isDataCache, cacheTimes).SumAsync(field);
|
||||
}
|
||||
#endregion
|
||||
@@ -1301,7 +1203,7 @@ namespace CoreCms.Net.Repository
|
||||
? DbBaseClient.Queryable<T>()
|
||||
.OrderByIF(!string.IsNullOrEmpty(orderBy), orderBy)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.With(SqlWith.NoLock)
|
||||
.WithNoLockOrNot(blUseNoLock)
|
||||
.WithCacheIF(isDataCache, cacheTimes)
|
||||
.ToPageList(pageIndex, pageSize, ref totalCount)
|
||||
: DbClient.Queryable<T>()
|
||||
@@ -1333,7 +1235,7 @@ namespace CoreCms.Net.Repository
|
||||
? await DbBaseClient.Queryable<T>()
|
||||
.OrderByIF(!string.IsNullOrEmpty(orderBy), orderBy)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.With(SqlWith.NoLock)
|
||||
.WithNoLockOrNot(blUseNoLock)
|
||||
.WithCacheIF(isDataCache, cacheTimes)
|
||||
.ToPageListAsync(pageIndex, pageSize, totalCount)
|
||||
: await DbBaseClient.Queryable<T>()
|
||||
@@ -1366,7 +1268,7 @@ namespace CoreCms.Net.Repository
|
||||
? DbBaseClient.Queryable<T>().
|
||||
OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.With(SqlWith.NoLock)
|
||||
.WithNoLockOrNot(blUseNoLock)
|
||||
.WithCacheIF(isDataCache, cacheTimes)
|
||||
.ToPageList(pageIndex, pageSize, ref totalCount)
|
||||
: DbBaseClient.Queryable<T>().
|
||||
@@ -1399,7 +1301,7 @@ namespace CoreCms.Net.Repository
|
||||
? await DbBaseClient.Queryable<T>()
|
||||
.WhereIF(predicate != null, predicate)
|
||||
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
||||
.With(SqlWith.NoLock)
|
||||
.WithNoLockOrNot(blUseNoLock)
|
||||
.WithCacheIF(isDataCache, cacheTimes)
|
||||
.ToPageListAsync(pageIndex, pageSize, totalCount)
|
||||
: await DbBaseClient.Queryable<T>()
|
||||
@@ -1435,10 +1337,10 @@ namespace CoreCms.Net.Repository
|
||||
{
|
||||
if (whereLambda == null)
|
||||
return blUseNoLock
|
||||
? DbBaseClient.Queryable(joinExpression).Select(selectExpression).With(SqlWith.NoLock).WithCacheIF(isDataCache, cacheTimes).ToList()
|
||||
? DbBaseClient.Queryable(joinExpression).Select(selectExpression).WithNoLockOrNot(blUseNoLock).WithCacheIF(isDataCache, cacheTimes).ToList()
|
||||
: DbBaseClient.Queryable(joinExpression).Select(selectExpression).WithCacheIF(isDataCache, cacheTimes).ToList();
|
||||
return blUseNoLock
|
||||
? DbBaseClient.Queryable(joinExpression).Where(whereLambda).Select(selectExpression).With(SqlWith.NoLock).WithCacheIF(isDataCache, cacheTimes).ToList()
|
||||
? DbBaseClient.Queryable(joinExpression).Where(whereLambda).Select(selectExpression).WithNoLockOrNot(blUseNoLock).WithCacheIF(isDataCache, cacheTimes).ToList()
|
||||
: DbBaseClient.Queryable(joinExpression).Where(whereLambda).Select(selectExpression).WithCacheIF(isDataCache, cacheTimes).ToList();
|
||||
}
|
||||
|
||||
@@ -1463,10 +1365,10 @@ namespace CoreCms.Net.Repository
|
||||
{
|
||||
if (whereLambda == null)
|
||||
return blUseNoLock
|
||||
? await DbBaseClient.Queryable(joinExpression).Select(selectExpression).With(SqlWith.NoLock).WithCacheIF(isDataCache, cacheTimes).ToListAsync()
|
||||
? await DbBaseClient.Queryable(joinExpression).Select(selectExpression).WithNoLockOrNot(blUseNoLock).WithCacheIF(isDataCache, cacheTimes).ToListAsync()
|
||||
: await DbBaseClient.Queryable(joinExpression).Select(selectExpression).WithCacheIF(isDataCache, cacheTimes).ToListAsync();
|
||||
return blUseNoLock
|
||||
? await DbBaseClient.Queryable(joinExpression).Where(whereLambda).Select(selectExpression).With(SqlWith.NoLock).WithCacheIF(isDataCache, cacheTimes).ToListAsync()
|
||||
? await DbBaseClient.Queryable(joinExpression).Where(whereLambda).Select(selectExpression).WithNoLockOrNot(blUseNoLock).WithCacheIF(isDataCache, cacheTimes).ToListAsync()
|
||||
: await DbBaseClient.Queryable(joinExpression).Where(whereLambda).Select(selectExpression).WithCacheIF(isDataCache, cacheTimes).ToListAsync();
|
||||
}
|
||||
|
||||
@@ -1491,10 +1393,10 @@ namespace CoreCms.Net.Repository
|
||||
{
|
||||
if (whereLambda == null)
|
||||
return blUseNoLock
|
||||
? DbBaseClient.Queryable(joinExpression).Select(selectExpression).With(SqlWith.NoLock).WithCacheIF(isDataCache, cacheTimes).First()
|
||||
? DbBaseClient.Queryable(joinExpression).Select(selectExpression).WithNoLockOrNot(blUseNoLock).WithCacheIF(isDataCache, cacheTimes).First()
|
||||
: DbBaseClient.Queryable(joinExpression).Select(selectExpression).WithCacheIF(isDataCache, cacheTimes).First();
|
||||
return blUseNoLock
|
||||
? DbBaseClient.Queryable(joinExpression).Where(whereLambda).Select(selectExpression).With(SqlWith.NoLock).WithCacheIF(isDataCache, cacheTimes).First()
|
||||
? DbBaseClient.Queryable(joinExpression).Where(whereLambda).Select(selectExpression).WithNoLockOrNot(blUseNoLock).WithCacheIF(isDataCache, cacheTimes).First()
|
||||
: DbBaseClient.Queryable(joinExpression).Where(whereLambda).Select(selectExpression).WithCacheIF(isDataCache, cacheTimes).First();
|
||||
}
|
||||
|
||||
@@ -1519,10 +1421,10 @@ namespace CoreCms.Net.Repository
|
||||
{
|
||||
if (whereLambda == null)
|
||||
return blUseNoLock
|
||||
? await DbBaseClient.Queryable(joinExpression).Select(selectExpression).With(SqlWith.NoLock).WithCacheIF(isDataCache, cacheTimes).FirstAsync()
|
||||
? await DbBaseClient.Queryable(joinExpression).Select(selectExpression).WithNoLockOrNot(blUseNoLock).WithCacheIF(isDataCache, cacheTimes).FirstAsync()
|
||||
: await DbBaseClient.Queryable(joinExpression).Select(selectExpression).WithCacheIF(isDataCache, cacheTimes).FirstAsync();
|
||||
return blUseNoLock
|
||||
? await DbBaseClient.Queryable(joinExpression).Where(whereLambda).Select(selectExpression).With(SqlWith.NoLock).WithCacheIF(isDataCache, cacheTimes).FirstAsync()
|
||||
? await DbBaseClient.Queryable(joinExpression).Where(whereLambda).Select(selectExpression).WithNoLockOrNot(blUseNoLock).WithCacheIF(isDataCache, cacheTimes).FirstAsync()
|
||||
: await DbBaseClient.Queryable(joinExpression).Where(whereLambda).Select(selectExpression).WithCacheIF(isDataCache, cacheTimes).FirstAsync();
|
||||
}
|
||||
|
||||
@@ -1548,10 +1450,10 @@ namespace CoreCms.Net.Repository
|
||||
{
|
||||
if (whereLambda == null)
|
||||
return blUseNoLock
|
||||
? DbBaseClient.Queryable(joinExpression).Select(selectExpression).With(SqlWith.NoLock).WithCacheIF(isDataCache, cacheTimes).ToList()
|
||||
? DbBaseClient.Queryable(joinExpression).Select(selectExpression).WithNoLockOrNot(blUseNoLock).WithCacheIF(isDataCache, cacheTimes).ToList()
|
||||
: DbBaseClient.Queryable(joinExpression).Select(selectExpression).WithCacheIF(isDataCache, cacheTimes).ToList();
|
||||
return blUseNoLock
|
||||
? DbBaseClient.Queryable(joinExpression).Where(whereLambda).Select(selectExpression).With(SqlWith.NoLock).WithCacheIF(isDataCache, cacheTimes).ToList()
|
||||
? DbBaseClient.Queryable(joinExpression).Where(whereLambda).Select(selectExpression).WithNoLockOrNot(blUseNoLock).WithCacheIF(isDataCache, cacheTimes).ToList()
|
||||
: DbBaseClient.Queryable(joinExpression).Where(whereLambda).Select(selectExpression).WithCacheIF(isDataCache, cacheTimes).ToList();
|
||||
}
|
||||
|
||||
@@ -1577,10 +1479,10 @@ namespace CoreCms.Net.Repository
|
||||
{
|
||||
if (whereLambda == null)
|
||||
return blUseNoLock
|
||||
? await DbBaseClient.Queryable(joinExpression).Select(selectExpression).With(SqlWith.NoLock).WithCacheIF(isDataCache, cacheTimes).ToListAsync()
|
||||
? await DbBaseClient.Queryable(joinExpression).Select(selectExpression).WithNoLockOrNot(blUseNoLock).WithCacheIF(isDataCache, cacheTimes).ToListAsync()
|
||||
: await DbBaseClient.Queryable(joinExpression).Select(selectExpression).WithCacheIF(isDataCache, cacheTimes).ToListAsync();
|
||||
return blUseNoLock
|
||||
? await DbBaseClient.Queryable(joinExpression).Where(whereLambda).Select(selectExpression).With(SqlWith.NoLock).WithCacheIF(isDataCache, cacheTimes).ToListAsync()
|
||||
? await DbBaseClient.Queryable(joinExpression).Where(whereLambda).Select(selectExpression).WithNoLockOrNot(blUseNoLock).WithCacheIF(isDataCache, cacheTimes).ToListAsync()
|
||||
: await DbBaseClient.Queryable(joinExpression).Where(whereLambda).Select(selectExpression).WithCacheIF(isDataCache, cacheTimes).ToListAsync();
|
||||
}
|
||||
#endregion
|
||||
|
||||
19
CoreCms.Net.Repository/SqlSugarExtensions.cs
Normal file
19
CoreCms.Net.Repository/SqlSugarExtensions.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Repository
|
||||
{
|
||||
internal static class SqlSugarExtensions
|
||||
{
|
||||
internal static ISugarQueryable<T> WithNoLockOrNot<T>(this ISugarQueryable<T> query, bool @lock = false)
|
||||
{
|
||||
if (@lock)
|
||||
{
|
||||
query = query.With(SqlWith.NoLock);
|
||||
}
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -581,7 +581,7 @@ namespace CoreCms.Net.Services
|
||||
var paymentRelData = new CheckPayDTO();
|
||||
|
||||
var sourceStrArr = sourceStr.Split(",");
|
||||
if (sourceStrArr.Length > 0)
|
||||
if (sourceStrArr.Length > 1)
|
||||
{
|
||||
var paymentRel = await BatchFormatPaymentRel(sourceStrArr, type, @params);
|
||||
if (paymentRel.status == false)
|
||||
|
||||
Reference in New Issue
Block a user