mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2025-12-06 17:33:27 +08:00
【优化】仓储单个数据查询增加悲观锁等待模式。
【优化】通过优惠券编码领取优惠券增加事务处理。
This commit is contained in:
@@ -298,10 +298,12 @@ namespace CoreCms.Net.Services
|
||||
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
|
||||
/// <param name="isDataCache">是否启用缓存</param>
|
||||
/// <param name="cacheTimes">缓存时长(分钟)</param>
|
||||
/// <param name="blUseTranLock">是否使用锁</param>
|
||||
/// <param name="dbLockType">数据锁类型</param>
|
||||
/// <returns></returns>
|
||||
public async Task<T> QueryByClauseAsync(Expression<Func<T, bool>> predicate, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue)
|
||||
public async Task<T> QueryByClauseAsync(Expression<Func<T, bool>> predicate, bool blUseNoLock = false, bool isDataCache = false, int cacheTimes = int.MaxValue, bool blUseTranLock = false, DbLockType dbLockType = DbLockType.Wait)
|
||||
{
|
||||
return await BaseDal.QueryByClauseAsync(predicate, blUseNoLock, isDataCache, cacheTimes);
|
||||
return await BaseDal.QueryByClauseAsync(predicate, blUseNoLock, isDataCache, cacheTimes, blUseTranLock, dbLockType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -329,28 +331,15 @@ namespace CoreCms.Net.Services
|
||||
/// <param name="blUseNoLock">是否使用WITH(NoLock)</param>
|
||||
/// <param name="isDataCache">是否启用缓存</param>
|
||||
/// <param name="cacheTimes">缓存时长(分钟)</param>
|
||||
/// <param name="blUseTranLock">是否使用锁</param>
|
||||
/// <param name="dbLockType">数据锁类型</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)
|
||||
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, bool blUseTranLock = false, DbLockType dbLockType = DbLockType.Wait)
|
||||
{
|
||||
return await BaseDal.QueryByClauseAsync(predicate, orderByPredicate, orderByType, blUseNoLock, isDataCache, cacheTimes);
|
||||
return await BaseDal.QueryByClauseAsync(predicate, orderByPredicate, orderByType, blUseNoLock, isDataCache, cacheTimes, blUseTranLock, dbLockType);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 根据条件查询数据(悲观锁等待模式)
|
||||
/// </summary>
|
||||
/// <param name="predicate">条件表达式树</param>
|
||||
/// <param name="orderByPredicate">排序字段</param>
|
||||
/// <param name="orderByType">排序顺序</param>
|
||||
/// <param name="blUseTranLock">是否使用TranLock</param>
|
||||
/// <param name="isDataCache">是否启用缓存</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)
|
||||
{
|
||||
return await BaseDal.QueryByClauseWithTranLockAsync(predicate, orderByPredicate, orderByType, blUseTranLock, isDataCache, cacheTimes);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 插入数据
|
||||
|
||||
@@ -694,7 +694,7 @@ namespace CoreCms.Net.Services
|
||||
where = where.And(p => p.isDel == false); //是否被删除
|
||||
|
||||
|
||||
var info = await _dal.QueryByClauseAsync(where);
|
||||
var info = await _dal.QueryByClauseAsync(where, false, true);
|
||||
if (info != null)
|
||||
{
|
||||
jm.data = info;
|
||||
|
||||
Reference in New Issue
Block a user