Browse Source

db.UpdateNav difference logs that support primary tables

pull/23/head
sunkaixuan 2 years ago
parent
commit
4653f5016d
  1. 17
      Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/UpdateNavProvider.cs
  2. 9
      Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs
  3. 8
      Src/Asp.Net/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs
  4. 2
      Src/Asp.Net/SqlSugar/Entities/DeleteNavOptions.cs
  5. 1
      Src/Asp.Net/SqlSugar/Interface/IUpdateable.cs
  6. 1
      Src/Asp.Net/SqlSugar/Interface/Insertable.cs

17
Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/UpdateNavProvider.cs

@ -132,35 +132,40 @@ namespace SqlSugar
com(updateable);
updateable.ExecuteCommand();
}
else if (IsFirst && _RootOptions != null)
else if (IsFirst && _RootOptions != null)
{
var isInsert = _RootOptions.IsInsertRoot;
if (isInsert)
{
var newRoots=new List<Root>();
var newRoots = new List<Root>();
foreach (var item in _Roots)
{
var x = this._Context.Storageable(item).ToStorage();
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);
}
}
_ParentList=_RootList=newRoots.Cast<object>().ToList();
_ParentList = _RootList = newRoots.Cast<object>().ToList();
}
else
{
this._Context.Updateable(_Roots)
.EnableDiffLogEventIF(_RootOptions.IsDiffLogEvent,_RootOptions.DiffLogBizData)
.UpdateColumns(_RootOptions.UpdateColumns)
.IgnoreColumns(_RootOptions.IgnoreColumns)
.ExecuteCommand();
}
}
else if (_RootOptions != null && _RootOptions?.IsDiffLogEvent == true)
{
this._Context.Updateable(_Roots).EnableDiffLogEvent(_RootOptions.DiffLogBizData).ExecuteCommand();
}
else
{
this._Context.Updateable(_Roots).ExecuteCommand();

9
Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs

@ -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)
{
//Check.Exception(this.InsertObjs.HasValue() && this.InsertObjs.Count() > 1, "DiffLog does not support batch operations");

8
Src/Asp.Net/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs

@ -198,6 +198,14 @@ namespace SqlSugar
this.Context.MappingTables.Add(entityName, tableName);
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)
{
//Check.Exception(this.UpdateObjs.HasValue() && this.UpdateObjs.Count() > 1, "DiffLog does not support batch operations");

2
Src/Asp.Net/SqlSugar/Entities/DeleteNavOptions.cs

@ -27,6 +27,8 @@ namespace SqlSugar
public string IgnoreColumns { get; set; }
public string[] UpdateColumns { get; set; }
public bool IsInsertRoot { get; set; }
public bool IsDiffLogEvent { get; set; }
public object DiffLogBizData { get; set; }
}
public class UpdateNavOptions
{

1
Src/Asp.Net/SqlSugar/Interface/IUpdateable.cs

@ -92,6 +92,7 @@ namespace SqlSugar
IUpdateable<T> IsEnableUpdateVersionValidation();
IUpdateable<T> EnableDiffLogEvent(object businessData = null);
IUpdateable<T> EnableDiffLogEventIF(bool isEnableDiffLog,object businessData = null);
IUpdateable<T> ReSetValue(Action<T> setValueExpression);
IUpdateable<T> RemoveDataCache();
IUpdateable<T> RemoveDataCache(string likeString);

1
Src/Asp.Net/SqlSugar/Interface/Insertable.cs

@ -40,6 +40,7 @@ namespace SqlSugar
IInsertable<T> CallEntityMethod(Expression<Action<T>> method);
IInsertable<T> EnableDiffLogEvent(object businessData = null);
IInsertable<T> EnableDiffLogEventIF(bool isDiffLogEvent, object businessData=null);
IInsertable<T> RemoveDataCache();
IInsertable<T> RemoveDataCache(string likeString);
KeyValuePair<string, List<SugarParameter>> ToSql();

Loading…
Cancel
Save