mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-24 04:53:45 +08:00
Navigation update optlock
This commit is contained in:
@@ -168,7 +168,7 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
x.AsUpdateable.EnableDiffLogEventIF(_RootOptions.IsDiffLogEvent, _RootOptions.DiffLogBizData).ExecuteCommand();
|
x.AsUpdateable.EnableDiffLogEventIF(_RootOptions.IsDiffLogEvent, _RootOptions.DiffLogBizData).ExecuteCommandWithOptLockIF(_RootOptions?.IsOptLock, _RootOptions?.IsOptLock);
|
||||||
newRoots.Add(item);
|
newRoots.Add(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -180,7 +180,7 @@ namespace SqlSugar
|
|||||||
.EnableDiffLogEventIF(_RootOptions.IsDiffLogEvent,_RootOptions.DiffLogBizData)
|
.EnableDiffLogEventIF(_RootOptions.IsDiffLogEvent,_RootOptions.DiffLogBizData)
|
||||||
.UpdateColumns(_RootOptions.UpdateColumns)
|
.UpdateColumns(_RootOptions.UpdateColumns)
|
||||||
.IgnoreColumns(_RootOptions.IgnoreColumns)
|
.IgnoreColumns(_RootOptions.IgnoreColumns)
|
||||||
.ExecuteCommand();
|
.ExecuteCommandWithOptLockIF(_RootOptions?.IsOptLock, _RootOptions?.IsOptLock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (_RootOptions != null && _RootOptions?.IsDiffLogEvent == true)
|
else if (_RootOptions != null && _RootOptions?.IsDiffLogEvent == true)
|
||||||
|
@@ -98,17 +98,17 @@ namespace SqlSugar
|
|||||||
|
|
||||||
public virtual List<TResult> ToList<TResult>(Expression<Func<T, TResult>> expression)
|
public virtual List<TResult> ToList<TResult>(Expression<Func<T, TResult>> expression)
|
||||||
{
|
{
|
||||||
//if (this.QueryBuilder.Includes != null && this.QueryBuilder.Includes.Count > 0)
|
if (this.QueryBuilder.Includes != null && this.QueryBuilder.Includes.Count > 0)
|
||||||
//{
|
{
|
||||||
// return NavSelectHelper.GetList(expression, this);
|
return NavSelectHelper.GetList(expression, this);
|
||||||
// // var list = this.ToList().Select(expression.Compile()).ToList();
|
// var list = this.ToList().Select(expression.Compile()).ToList();
|
||||||
// // return list;
|
// return list;
|
||||||
//}
|
}
|
||||||
//else
|
else
|
||||||
//{
|
{
|
||||||
var list = this.Select(expression).ToList();
|
var list = this.Select(expression).ToList();
|
||||||
return list;
|
return list;
|
||||||
//}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual int Count()
|
public virtual int Count()
|
||||||
@@ -668,21 +668,21 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
public virtual List<TResult> ToPageList<TResult>(int pageIndex, int pageSize, ref int totalNumber, Expression<Func<T, TResult>> expression)
|
public virtual List<TResult> ToPageList<TResult>(int pageIndex, int pageSize, ref int totalNumber, Expression<Func<T, TResult>> expression)
|
||||||
{
|
{
|
||||||
//if (this.QueryBuilder.Includes != null && this.QueryBuilder.Includes.Count > 0)
|
if (this.QueryBuilder.Includes != null && this.QueryBuilder.Includes.Count > 0)
|
||||||
//{
|
{
|
||||||
// if (pageIndex == 0)
|
if (pageIndex == 0)
|
||||||
// pageIndex = 1;
|
pageIndex = 1;
|
||||||
// var list = this.Clone().Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList(expression);
|
var list = this.Clone().Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList(expression);
|
||||||
// var countQueryable = this.Clone();
|
var countQueryable = this.Clone();
|
||||||
// countQueryable.QueryBuilder.Includes = null;
|
countQueryable.QueryBuilder.Includes = null;
|
||||||
// totalNumber = countQueryable.Count();
|
totalNumber = countQueryable.Count();
|
||||||
// return list;
|
return list;
|
||||||
//}
|
}
|
||||||
//else
|
else
|
||||||
//{
|
{
|
||||||
var list = this.Select(expression).ToPageList(pageIndex, pageSize, ref totalNumber).ToList();
|
var list = this.Select(expression).ToPageList(pageIndex, pageSize, ref totalNumber).ToList();
|
||||||
return list;
|
return list;
|
||||||
//}
|
}
|
||||||
}
|
}
|
||||||
public virtual List<T> ToPageList(int pageIndex, int pageSize, ref int totalNumber)
|
public virtual List<T> ToPageList(int pageIndex, int pageSize, ref int totalNumber)
|
||||||
{
|
{
|
||||||
|
@@ -64,7 +64,17 @@ namespace SqlSugar
|
|||||||
var sqlObj = this.ToSql();
|
var sqlObj = this.ToSql();
|
||||||
this.Context.Queues.Add(sqlObj.Key, sqlObj.Value);
|
this.Context.Queues.Add(sqlObj.Key, sqlObj.Value);
|
||||||
}
|
}
|
||||||
|
public virtual int ExecuteCommandWithOptLockIF(bool? IsVersionValidation ,bool? IsOptLock=null)
|
||||||
|
{
|
||||||
|
if (IsOptLock==true)
|
||||||
|
{
|
||||||
|
return ExecuteCommandWithOptLock(IsVersionValidation??false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return this.ExecuteCommand();
|
||||||
|
}
|
||||||
|
}
|
||||||
public virtual int ExecuteCommandWithOptLock(bool IsVersionValidation=false)
|
public virtual int ExecuteCommandWithOptLock(bool IsVersionValidation=false)
|
||||||
{
|
{
|
||||||
Check.ExceptionEasy(this.UpdateBuilder.IsListUpdate==true, " OptLock can only be used on a single object, and the argument cannot be List", "乐观锁只能用于单个对象,参数不能是List,如果是一对多操作请更新主表统一用主表验证");
|
Check.ExceptionEasy(this.UpdateBuilder.IsListUpdate==true, " OptLock can only be used on a single object, and the argument cannot be List", "乐观锁只能用于单个对象,参数不能是List,如果是一对多操作请更新主表统一用主表验证");
|
||||||
|
@@ -38,6 +38,8 @@ namespace SqlSugar
|
|||||||
public bool IsDiffLogEvent { get; set; }
|
public bool IsDiffLogEvent { get; set; }
|
||||||
public object DiffLogBizData { get; set; }
|
public object DiffLogBizData { get; set; }
|
||||||
public string[] IgnoreInsertColumns { get; set; }
|
public string[] IgnoreInsertColumns { get; set; }
|
||||||
|
public bool IsOptLock { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
public class UpdateNavOptions
|
public class UpdateNavOptions
|
||||||
{
|
{
|
||||||
|
@@ -15,6 +15,7 @@ namespace SqlSugar
|
|||||||
bool UpdateParameterIsNull { get; set; }
|
bool UpdateParameterIsNull { get; set; }
|
||||||
|
|
||||||
int ExecuteCommandWithOptLock(bool isThrowError = false);
|
int ExecuteCommandWithOptLock(bool isThrowError = false);
|
||||||
|
int ExecuteCommandWithOptLockIF(bool? IsVersionValidation, bool? IsOptLock = null);
|
||||||
Task<int> ExecuteCommandWithOptLockAsync(bool isThrowError = false);
|
Task<int> ExecuteCommandWithOptLockAsync(bool isThrowError = false);
|
||||||
int ExecuteCommand();
|
int ExecuteCommand();
|
||||||
bool ExecuteCommandHasChange();
|
bool ExecuteCommandHasChange();
|
||||||
|
Reference in New Issue
Block a user