mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-10-15 18:55:07 +08:00
db.UpdateNav difference logs that support primary tables
This commit is contained in:
@@ -132,35 +132,40 @@ namespace SqlSugar
|
|||||||
com(updateable);
|
com(updateable);
|
||||||
updateable.ExecuteCommand();
|
updateable.ExecuteCommand();
|
||||||
}
|
}
|
||||||
else if (IsFirst && _RootOptions != null)
|
else if (IsFirst && _RootOptions != null)
|
||||||
{
|
{
|
||||||
var isInsert = _RootOptions.IsInsertRoot;
|
var isInsert = _RootOptions.IsInsertRoot;
|
||||||
if (isInsert)
|
if (isInsert)
|
||||||
{
|
{
|
||||||
var newRoots=new List<Root>();
|
var newRoots = new List<Root>();
|
||||||
foreach (var item in _Roots)
|
foreach (var item in _Roots)
|
||||||
{
|
{
|
||||||
var x = this._Context.Storageable(item).ToStorage();
|
var x = this._Context.Storageable(item).ToStorage();
|
||||||
if (x.InsertList.HasValue())
|
if (x.InsertList.HasValue())
|
||||||
{
|
{
|
||||||
newRoots.Add( x.AsInsertable.ExecuteReturnEntity());
|
newRoots.Add(x.AsInsertable.EnableDiffLogEventIF(_RootOptions.IsDiffLogEvent, _RootOptions.DiffLogBizData).ExecuteReturnEntity());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
x.AsUpdateable.ExecuteCommand();
|
x.AsUpdateable.EnableDiffLogEventIF(_RootOptions.IsDiffLogEvent, _RootOptions.DiffLogBizData).ExecuteCommand();
|
||||||
newRoots.Add(item);
|
newRoots.Add(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ParentList=_RootList=newRoots.Cast<object>().ToList();
|
_ParentList = _RootList = newRoots.Cast<object>().ToList();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this._Context.Updateable(_Roots)
|
this._Context.Updateable(_Roots)
|
||||||
|
.EnableDiffLogEventIF(_RootOptions.IsDiffLogEvent,_RootOptions.DiffLogBizData)
|
||||||
.UpdateColumns(_RootOptions.UpdateColumns)
|
.UpdateColumns(_RootOptions.UpdateColumns)
|
||||||
.IgnoreColumns(_RootOptions.IgnoreColumns)
|
.IgnoreColumns(_RootOptions.IgnoreColumns)
|
||||||
.ExecuteCommand();
|
.ExecuteCommand();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (_RootOptions != null && _RootOptions?.IsDiffLogEvent == true)
|
||||||
|
{
|
||||||
|
this._Context.Updateable(_Roots).EnableDiffLogEvent(_RootOptions.DiffLogBizData).ExecuteCommand();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this._Context.Updateable(_Roots).ExecuteCommand();
|
this._Context.Updateable(_Roots).ExecuteCommand();
|
||||||
|
@@ -499,7 +499,14 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public IInsertable<T> EnableDiffLogEventIF(bool isDiffLogEvent, object diffLogBizData)
|
||||||
|
{
|
||||||
|
if (isDiffLogEvent)
|
||||||
|
{
|
||||||
|
return EnableDiffLogEvent(diffLogBizData);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
public IInsertable<T> EnableDiffLogEvent(object businessData = null)
|
public IInsertable<T> EnableDiffLogEvent(object businessData = null)
|
||||||
{
|
{
|
||||||
//Check.Exception(this.InsertObjs.HasValue() && this.InsertObjs.Count() > 1, "DiffLog does not support batch operations");
|
//Check.Exception(this.InsertObjs.HasValue() && this.InsertObjs.Count() > 1, "DiffLog does not support batch operations");
|
||||||
|
@@ -198,6 +198,14 @@ namespace SqlSugar
|
|||||||
this.Context.MappingTables.Add(entityName, tableName);
|
this.Context.MappingTables.Add(entityName, tableName);
|
||||||
return this; ;
|
return this; ;
|
||||||
}
|
}
|
||||||
|
public IUpdateable<T> EnableDiffLogEventIF(bool isEnableDiffLog, object businessData = null)
|
||||||
|
{
|
||||||
|
if (isEnableDiffLog)
|
||||||
|
{
|
||||||
|
return EnableDiffLogEvent(businessData);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
public IUpdateable<T> EnableDiffLogEvent(object businessData = null)
|
public IUpdateable<T> EnableDiffLogEvent(object businessData = null)
|
||||||
{
|
{
|
||||||
//Check.Exception(this.UpdateObjs.HasValue() && this.UpdateObjs.Count() > 1, "DiffLog does not support batch operations");
|
//Check.Exception(this.UpdateObjs.HasValue() && this.UpdateObjs.Count() > 1, "DiffLog does not support batch operations");
|
||||||
|
@@ -27,6 +27,8 @@ namespace SqlSugar
|
|||||||
public string IgnoreColumns { get; set; }
|
public string IgnoreColumns { get; set; }
|
||||||
public string[] UpdateColumns { get; set; }
|
public string[] UpdateColumns { get; set; }
|
||||||
public bool IsInsertRoot { get; set; }
|
public bool IsInsertRoot { get; set; }
|
||||||
|
public bool IsDiffLogEvent { get; set; }
|
||||||
|
public object DiffLogBizData { get; set; }
|
||||||
}
|
}
|
||||||
public class UpdateNavOptions
|
public class UpdateNavOptions
|
||||||
{
|
{
|
||||||
|
@@ -92,6 +92,7 @@ namespace SqlSugar
|
|||||||
|
|
||||||
IUpdateable<T> IsEnableUpdateVersionValidation();
|
IUpdateable<T> IsEnableUpdateVersionValidation();
|
||||||
IUpdateable<T> EnableDiffLogEvent(object businessData = null);
|
IUpdateable<T> EnableDiffLogEvent(object businessData = null);
|
||||||
|
IUpdateable<T> EnableDiffLogEventIF(bool isEnableDiffLog,object businessData = null);
|
||||||
IUpdateable<T> ReSetValue(Action<T> setValueExpression);
|
IUpdateable<T> ReSetValue(Action<T> setValueExpression);
|
||||||
IUpdateable<T> RemoveDataCache();
|
IUpdateable<T> RemoveDataCache();
|
||||||
IUpdateable<T> RemoveDataCache(string likeString);
|
IUpdateable<T> RemoveDataCache(string likeString);
|
||||||
|
@@ -40,6 +40,7 @@ namespace SqlSugar
|
|||||||
IInsertable<T> CallEntityMethod(Expression<Action<T>> method);
|
IInsertable<T> CallEntityMethod(Expression<Action<T>> method);
|
||||||
|
|
||||||
IInsertable<T> EnableDiffLogEvent(object businessData = null);
|
IInsertable<T> EnableDiffLogEvent(object businessData = null);
|
||||||
|
IInsertable<T> EnableDiffLogEventIF(bool isDiffLogEvent, object businessData=null);
|
||||||
IInsertable<T> RemoveDataCache();
|
IInsertable<T> RemoveDataCache();
|
||||||
IInsertable<T> RemoveDataCache(string likeString);
|
IInsertable<T> RemoveDataCache(string likeString);
|
||||||
KeyValuePair<string, List<SugarParameter>> ToSql();
|
KeyValuePair<string, List<SugarParameter>> ToSql();
|
||||||
|
Reference in New Issue
Block a user